summaryrefslogtreecommitdiff
path: root/src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs
AgeCommit message (Collapse)AuthorFilesLines
2018-03-23Rename new Stream.Read/Write{Async} Span/Memory source/Destination arguments ↵Anirudh Agnihotry1-8/+8
to buffer (#17141) * changed to buffer * More Common changes * fixed * another fix
2018-02-28Implement ValueTask extensibilityStephen Toub1-1/+1
This commit adds support for extending `ValueTask<T>` with arbitrary backing sources. Prior to this change, `ValueTask<T>` could wrap a `T` or a `Task<T>`; now it can also wrap an `IValueTaskSource<T>`, which can be implemented by arbitrary objects to be represented by `ValueTask<T>`. These objects can then be pooled and reused to minimize allocation. The commit also adds a non-generic `ValueTask` that can represent void-returning operations, including a `default` synchronous success, `Task`, and `IValueTaskSource`. For the non-generic `ValueTask`, the commit also includes awaiters and async method builders, so it can be both awaited and used as the return type of an async method. The rest of the changes fall into a few buckets all related to enabling this support: - Modifying `AsyncTaskMethodBuilder<TResult>.AwaitUnsafeOnCompleted` to specially recognize any `ValueTask` and utilize either the `Task` or `IValueTaskSource` that backs it to avoid allocating an Action MoveNext method. If every object awaited in an async method is either a `Task`/`Task<T>` or `ValueTask`/`ValueTask<T>`, regardless of what the `ValueTask`/`ValueTask<T>` wraps, we'll be able to avoid allocating the delegate and only allocate the single state machine object that also serves as the returned object. - Changing `Stream.WriteAsync` to return `ValueTask` instead of `Task`. This enables interested overriding stream types to use a reusable/pooled object to avoid `WriteAsync` allocations. - Modifying Stream.CopyToAsync to use the new `Memory`-based overloads of `ReadAsync` and `WriteAsync`. This enables the default `CopyToAsync` implementation to take advantage of any pooling done by derived streams, but even without pooling to take advantage of synchronously completing `ReadAsync`s returning `ValueTask<int>`s that contained an `int` rather than an allocated object. (While I was modifying this, I also removed some unnecessary array clearing that we'd added before later deciding it wasn't needed in general.) - Modifying StreamReader/Writer to use the new `ReadAsync`/`WriteAsync` overloads.
2017-09-26Replace Contract.Assumes and Contract.Assert with Debug.Assert/Debug.Fail ↵Dan Moseley1-4/+0
(#14136) * Remove use of Contract.Assert and Contract.Assumes in favor of Debug.xx * Remove dead IA64 blocks * Remove use of Contract.Requires in favor of Debug.Assert * Remove Contract.EndContractBlock() * Dead comments * Straggler EndcontractBlock * Remove all Contract.Ensures * Remove [Pure] attribute and using statements * Remove using statements for M.D.Contracts.Internal.Contract * Rmove CA suppressions for Contracts * Remove M.D.Contracts.Internal stub * Comments and extra using * Revert accidentallly removed #if * Unix build * Merge Math* * Fix assert not updated since desktop * Asserts add no value: remove * Avoid infinite recursion in StringBuilder assert * Remove asserts that should be public parameter validation * Fix comment * Remove blank line after open curly
2017-09-06Add Memory-based Stream overloads to coreclr (#13769)Stephen Toub1-0/+10
Includes adding the virtuals to Stream and then overriding on the various streams implemented in coreclr.
2017-07-27Add new Span-based virtual sync Read/Write Stream methods (#13058)Stephen Toub1-0/+10
* Add virtual Stream.Read/Write Span-based APIs * Override Span-based Read/Write on MemoryStream * Override Span-based Read/Write on UnmanagedMemoryStream * Address PR feedback
2017-05-04Move UnmanagedMemoryStream and related types to shared CoreLib partition ↵Jan Kotas1-0/+210
(#11409)