System.IO.Pipelines Provides support for efficiently using Tasks to implement the APM (Begin/End) pattern. Marshals the Task as an IAsyncResult, using the supplied callback and state to implement the APM pattern. The Task to be marshaled. The callback to be invoked upon completion. The state to be stored in the IAsyncResult. An IAsyncResult to represent the task's asynchronous operation. Processes an IAsyncResult returned by Begin. The IAsyncResult to unwrap. Processes an IAsyncResult returned by Begin. The IAsyncResult to unwrap. Gets the task represented by the IAsyncResult. Throws an argument exception for the invalid . Provides a simple IAsyncResult that wraps a Task. We could use the Task as the IAsyncResult if the Task's AsyncState is the same as the object state, but that's very rare, in particular in a situation where someone cares about allocation, and always using TaskAsyncResult simplifies things and enables additional optimizations. The wrapped Task. Callback to invoke when the wrapped task completes. Initializes the IAsyncResult with the Task to wrap and the associated object state. The Task to wrap. The new AsyncState value. Callback to invoke when the wrapped task completes. Invokes the callback. Gets a user-defined object that qualifies or contains information about an asynchronous operation. Gets a value that indicates whether the asynchronous operation completed synchronously. This is set lazily based on whether the has completed by the time this object is created. Gets a value that indicates whether the asynchronous operation has completed. Gets a that is used to wait for an asynchronous operation to complete. The End represents the offset into AvailableMemory where the range of "active" bytes ends. At the point when the block is leased the End is guaranteed to be equal to Start. The value of Start may be assigned anywhere between 0 and Buffer.Length, and must be equal to or less than End. Reference to the next block of data when the overall "active" bytes spans multiple blocks. At the point when the block is leased Next is guaranteed to be null. Start, End, and Next are used together in order to create a linked-list of discontiguous working memory. The "active" memory is grown when bytes are copied in, End is increased, and Next is assigned. The "active" memory is shrunk when bytes are consumed, Start is increased, and blocks are returned to the pool. Result returned by call. Initializes a new instance of struct setting the and flags. to indicate the current operation that produced this was canceled by ; otherwise, . to indicate the reader is no longer reading data written to the . Gets a value that indicates whether the current operation was canceled by . if the current operation was canceled by ; otherwise, . Gets a value that indicates the reader is no longer reading data written to the . if the reader is no longer reading data written to the ; otherwise, . Defines a class that provides a duplex pipe from which data can be read from and written to. Gets the half of the duplex pipe. Gets the half of the duplex pipe. A simple struct we wrap reference types inside when storing in arrays to bypass the CLR's covariant checks when writing to arrays. We use as a wrapper to avoid paying the cost of covariant checks whenever the underlying array that the class uses is written to. We've recognized this as a perf win in ETL traces for these stack frames: clr!JIT_Stelem_Ref clr!ArrayStoreCheck clr!ObjIsInstanceOf The default and implementation. The default and implementation. The default and implementation. Initializes a new instance of the class using as options. Initializes a new instance of the class with the specified options. The set of options for this pipe. Gets the for this pipe. A instance for this pipe. Gets the for this pipe. A instance for this pipe. Resets the pipe. Represents a set of options. Gets the default instance of . A object initialized with default parameters. Initializes a new instance of the class with the specified parameters. The pool of memory blocks to be used for buffer management. The to be used to execute callbacks and async continuations. The used to execute callbacks and async continuations. The number of bytes in the before starts blocking. A value of zero prevents from ever blocking, effectively making the number of bytes in the unlimited. The number of bytes in the when stops blocking. The minimum size of the segment requested from . if asynchronous continuations should be executed on the they were captured on; otherwise. This takes precedence over the schedulers specified in and . Gets a value that determines if asynchronous callbacks and continuations should be executed on the they were captured on. This takes precedence over the schedulers specified in and . if asynchronous callbacks and continuations should be executed on the they were captured on; otherwise, . Gets the number of bytes in the when starts blocking. The number of bytes in the when starts blocking. Gets the number of bytes in the when stops blocking. The number of bytes in the when stops blocking. Gets the minimum size of the segment requested from the . The minimum size of the segment requested from the . Gets the used to execute callbacks and async continuations. A object used to execute callbacks and async continuations. Gets the used to execute callbacks and async continuations. A that is used to execute callbacks and async continuations. Gets the object used for buffer management. A pool of memory blocks used for buffer management. Returns true if Pool is .Shared The initialize size of the segment pool The maximum number of segments to pool Defines a class that provides access to a read side of pipe. Attempts to synchronously read data from the . When this method returns , this value is set to a instance that represents the result of the read call; otherwise, this value is set to . if data was available, or if the call was canceled or the writer was completed; otherwise, . If the pipe returns , there is no need to call . Asynchronously reads a sequence of bytes from the current . The token to monitor for cancellation requests. The default value is . A representing the asynchronous read operation. Asynchronously reads a sequence of bytes from the current . The minimum length that needs to be buffered in order to for the call to return. The token to monitor for cancellation requests. The default value is . A representing the asynchronous read operation. The call returns if the has read the minimumLength specified, or is cancelled or completed. Asynchronously reads a sequence of bytes from the current . The minimum length that needs to be buffered in order to for the call to return. The token to monitor for cancellation requests. The default value is . A representing the asynchronous read operation. The call returns if the has read the minimumLength specified, or is cancelled or completed. Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed. Marks the extent of the data that has been successfully processed. The memory for the consumed data will be released and no longer available. The previously returned from must not be accessed after this call. This is equivalent to calling with identical examined and consumed positions. The examined data communicates to the pipeline when it should signal more data is available. Because the consumed parameter doubles as the examined parameter, the consumed parameter should be greater than or equal to the examined position in the previous call to `AdvanceTo`. Otherwise, an is thrown. Moves forward the pipeline's read cursor to after the consumed data, marking the data as processed, read and examined. Marks the extent of the data that has been successfully processed. Marks the extent of the data that has been read and examined. The memory for the consumed data will be released and no longer available. The previously returned from must not be accessed after this call. The examined data communicates to the pipeline when it should signal more data is available. The examined parameter should be greater than or equal to the examined position in the previous call to `AdvanceTo`. Otherwise, an is thrown. Returns a representation of the . An optional flag that indicates whether disposing the returned leaves open () or completes (). A stream that represents the . Cancels the pending operation without causing it to throw and without completing the . If there is no pending operation, this cancels the next operation. The canceled operation returns a where is . Signals to the producer that the consumer is done reading. Optional indicating a failure that's causing the pipeline to complete. Marks the current pipe reader instance as being complete, meaning no more data will be read from it. An optional exception that indicates the failure that caused the reader to complete. A value task that represents the asynchronous complete operation. Registers a callback that executes when the side of the pipe is completed. The callback to register. The state object to pass to when it's invoked. [!IMPORTANT] > `OnWriterCompleted` may not be invoked on all implementations of . This method will be removed in a future release. ]]> Creates a wrapping the specified . The stream that the pipe reader will wrap. The options to configure the pipe reader. A that wraps the . Creates a wrapping the specified . The sequence. A that wraps the . Asynchronously reads the bytes from the and writes them to the specified , using a specified buffer size and cancellation token. The pipe writer to which the contents of the current stream will be copied. The token to monitor for cancellation requests. The default value is . A task that represents the asynchronous copy operation. Asynchronously reads the bytes from the and writes them to the specified stream, using a specified cancellation token. The stream to which the contents of the current stream will be copied. The token to monitor for cancellation requests. The default value is . A task that represents the asynchronous copy operation. Abstraction for running and callbacks and continuations. The implementation that queues callbacks to the thread pool. A instance that queues callbacks to the thread pool. The implementation that runs callbacks inline. A instance that runs callbacks inline. Requests to be run on scheduler with being passed in. The single-parameter action delegate to schedule. The parameter to pass to the delegate. Defines a class that provides a pipeline to which data can be written. Marks the as being complete, meaning no more items will be written to it. Optional indicating a failure that's causing the pipeline to complete. Marks the current pipe writer instance as being complete, meaning no more data will be written to it. An optional exception that indicates the failure that caused the pipeline to complete. A value task that represents the asynchronous complete operation. Cancels the pending or operation without causing the operation to throw and without completing the . If there is no pending operation, this cancels the next operation. The canceled or operation returns a where is . Gets a value that indicates whether the current supports reporting the count of unflushed bytes. If a class derived from does not support getting the unflushed bytes, calls to throw . Registers a callback that executes when the side of the pipe is completed. The callback to register. The state object to pass to when it's invoked. [!IMPORTANT] > `OnReaderCompleted` may not be invoked on all implementations of . This method will be removed in a future release. ]]> Makes bytes written available to and runs continuation. The token to monitor for cancellation requests. The default value is . A task that represents and wraps the asynchronous flush operation. Notifies the that bytes were written to the output or . You must request a new buffer after calling to continue writing more data; you cannot write to a previously acquired buffer. The number of bytes written to the or . Returns a to write to that is at least the requested size, as specified by the parameter. The minimum length of the returned . If 0, a non-empty memory buffer of arbitrary size is returned. A memory buffer of at least bytes. If is 0, returns a non-empty buffer of arbitrary size. There is no guarantee that successive calls will return the same buffer or the same-sized buffer. This method never returns , but it throws an if the requested buffer size is not available. You must request a new buffer after calling to continue writing more data; you cannot write to a previously acquired buffer. The requested buffer size is not available. Returns a to write to that is at least the requested size, as specified by the parameter. The minimum length of the returned . If 0, a non-empty buffer of arbitrary size is returned. A buffer of at least bytes. If is 0, returns a non-empty buffer of arbitrary size. There is no guarantee that successive calls will return the same buffer or the same-sized buffer. This method never returns , but it throws an if the requested buffer size is not available. You must request a new buffer after calling to continue writing more data; you cannot write to a previously acquired buffer. The requested buffer size is not available. Returns a representation of the . An optional flag that indicates whether disposing the returned leaves open () or completes (). A stream that represents the . Creates a wrapping the specified . The stream that the pipe writer will wrap. The options to configure the pipe writer. A that wraps the . Writes the specified byte memory range to the pipe and makes data accessible to the . The read-only byte memory region to write. The token to monitor for cancellation requests. The default value is . A task that represents the asynchronous write operation, and wraps the flush asynchronous operation. Asynchronously reads the bytes from the specified stream and writes them to the . The stream from which the contents will be copied. The token to monitor for cancellation requests. The default value is . A task that represents the asynchronous copy operation. When overridden in a derived class, gets the count of unflushed bytes within the current writer. The does not support getting the unflushed byte count. Represents the result of a call. Creates a new instance of setting and flags. The read-only sequence containing the bytes of data that were read in the call. A flag that indicates if the operation that produced this was canceled by . A flag that indicates whether the end of the data stream has been reached. Gets the that was read. A read-only sequence containing the bytes of data that were read in the call. Gets a value that indicates whether the current operation was canceled by . if the operation that produced this was canceled by ; otherwise, . Gets a value that indicates whether the end of the data stream has been reached. if the end of the data stream has been reached; otherwise, . Provides extension methods for that support read and write operations directly into pipes. Asynchronously reads the bytes from the and writes them to the specified , using a cancellation token. The stream from which the contents of the current stream will be copied. The writer to which the contents of the source stream will be copied. The token to monitor for cancellation requests. The default value is . A task that represents the asynchronous copy operation. Creates a new StreamPipeReader. The stream to read from. The options to use. Gets the inner stream that is being read from. Represents a set of options for controlling the creation of the . Initializes a instance, optionally specifying a memory pool, a minimum buffer size, a minimum read size, and whether the underlying stream should be left open after the completes. The memory pool to use when allocating memory. The default value is . The minimum buffer size to use when renting memory from the . The default value is 4096. The threshold of remaining bytes in the buffer before a new buffer is allocated. The default value is 1024. to leave the underlying stream open after the completes; to close it. The default is . Initializes a instance, optionally specifying a memory pool, a minimum buffer size, a minimum read size, and whether the underlying stream should be left open after the completes. The memory pool to use when allocating memory. The default value is . The minimum buffer size to use when renting memory from the . The default value is 4096. The threshold of remaining bytes in the buffer before a new buffer is allocated. The default value is 1024. to leave the underlying stream open after the completes; to close it. The default is . if reads with an empty buffer should be issued to the underlying stream before allocating memory; otherwise, . Gets the minimum buffer size to use when renting memory from the . The buffer size. Gets the maximum buffer size to use when renting memory from the . The maximum buffer size. Gets the threshold of remaining bytes in the buffer before a new buffer is allocated. The minimum read size. Gets the to use when allocating memory. A memory pool instance. Gets the value that indicates if the underlying stream should be left open after the completes. if the underlying stream should be left open after the completes; otherwise, . Gets the value that indicates if reads with an empty buffer should be issued to the underlying stream, in order to wait for data to arrive before allocating memory. if reads with an empty buffer should be issued to the underlying stream before allocating memory; otherwise, . Returns true if Pool is .Shared Gets the inner stream that is being written to. Represents a set of options for controlling the creation of the . Initializes a instance, optionally specifying a memory pool, a minimum buffer size, and whether the underlying stream should be left open after the completes. The memory pool to use when allocating memory. The default value is . The minimum buffer size to use when renting memory from the . The default value is 4096. to leave the underlying stream open after the completes; to close it. The default is . Gets the minimum buffer size to use when renting memory from the . An integer representing the minimum buffer size. Gets the to use when allocating memory. A memory pool instance. Gets the value that indicates if the underlying stream should be left open after the completes. if the underlying stream should be left open after the completes; otherwise, . Provides methods to help in the implementation of Stream-derived types. Validate the arguments to CopyTo, as would Stream.CopyTo. The PipeReader has already advanced past the provided position. Positive number required. Concurrent reads or writes are not supported. Flush was canceled on underlying PipeWriter. Can't GetResult unless awaiter is completed. The examined position must be greater than or equal to the consumed position. The examined position cannot be less than the previously examined position. The PipeReader returned 0 bytes when the ReadResult was not completed or canceled. Cannot access a closed stream. No reading operation to complete. Stream does not support reading. Stream does not support writing. Read was canceled on underlying PipeReader. Both reader and writer has to be completed to be able to reset the pipe. Reading is not allowed after reader was completed. Reading is already in progress. Writing is not allowed after writer was completed. UnflushedBytes is not supported. Specifies that null is allowed as an input even if the corresponding type disallows it. Specifies that null is disallowed as an input even if the corresponding type allows it. Specifies that an output may be null even if the corresponding type disallows it. Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns. Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter may be null. Gets the return value condition. Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter will not be null. Gets the return value condition. Specifies that the output will be non-null if the named parameter is non-null. Initializes the attribute with the associated parameter name. The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. Gets the associated parameter name. Applied to a method that will never return under any circumstance. Specifies that the method will not return if the associated Boolean parameter is passed the specified value. Initializes the attribute with the specified parameter value. The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to the associated parameter matches this value. Gets the condition parameter value. Specifies that the method or property will ensure that the listed field and property members have not-null values. Initializes the attribute with a field or property member. The field or property member that is promised to be not-null. Initializes the attribute with the list of field and property members. The list of field and property members that are promised to be not-null. Gets field or property member names. Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition. Initializes the attribute with the specified return value condition and a field or property member. The return value condition. If the method returns this value, the associated parameter will not be null. The field or property member that is promised to be not-null. Initializes the attribute with the specified return value condition and list of field and property members. The return value condition. If the method returns this value, the associated parameter will not be null. The list of field and property members that are promised to be not-null. Gets the return value condition. Gets field or property member names.