A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://dotnet.github.io/dotNext/api/DotNext.IO.PoolingBufferedStream.html below:

Class PoolingBufferedStream | .NEXT

Class PoolingBufferedStream

Represents alternative implementation of BufferedStream that supports memory pooling.

Inheritance

PoolingBufferedStream

Namespace: DotNext.IO Assembly: DotNext.IO.dll Syntax
public sealed class PoolingBufferedStream : Stream, IAsyncDisposable, IBufferedWriter, IBufferWriter<byte>, IFlushable, IBufferedReader, IBufferedChannel, IResettable, IDisposable
Constructors | Edit this page View Source PoolingBufferedStream(Stream, bool)

Represents alternative implementation of BufferedStream that supports memory pooling.

Declaration
public PoolingBufferedStream(Stream stream, bool leaveOpen = false)
Parameters Type Name Description Stream stream

The underlying stream to be buffered.

bool leaveOpen

true to leave stream open after the object is disposed; otherwise, false.

Properties | Edit this page View Source Allocator

Gets or sets buffer allocator.

Declaration
public MemoryAllocator<byte>? Allocator { get; init; }
Property Value | Edit this page View Source BaseStream

Gets the base stream.

Declaration
public Stream BaseStream { get; }
Property Value | Edit this page View Source CanRead

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

Declaration
public override bool CanRead { get; }
Property Value Type Description bool

true if the stream supports reading; otherwise, false.

Overrides | Edit this page View Source CanSeek

When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

Declaration
public override bool CanSeek { get; }
Property Value Type Description bool

true if the stream supports seeking; otherwise, false.

Overrides | Edit this page View Source CanTimeout

Gets a value that determines whether the current stream can time out.

Declaration
public override bool CanTimeout { get; }
Property Value Type Description bool

A value that determines whether the current stream can time out.

Overrides | Edit this page View Source CanWrite

When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Declaration
public override bool CanWrite { get; }
Property Value Type Description bool

true if the stream supports writing; otherwise, false.

Overrides | Edit this page View Source HasBufferedDataToRead

Gets a value indicating that the stream has data in read buffer.

Declaration
public bool HasBufferedDataToRead { get; }
Property Value | Edit this page View Source HasBufferedDataToWrite

Gets a value indicating that the stream has buffered data in write buffer.

Declaration
public bool HasBufferedDataToWrite { get; }
Property Value | Edit this page View Source Length

When overridden in a derived class, gets the length in bytes of the stream.

Declaration
public override long Length { get; }
Property Value Type Description long

A long value representing the length of the stream in bytes.

Overrides Exceptions | Edit this page View Source MaxBufferSize

Gets the maximum size of the internal buffer, in bytes.

Declaration
public int MaxBufferSize { get; init; }
Property Value | Edit this page View Source Position

When overridden in a derived class, gets or sets the position within the current stream.

Declaration
public override long Position { get; set; }
Property Value Type Description long

The current position within the stream.

Overrides Exceptions | Edit this page View Source ReadTimeout

Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.

Declaration
public override int ReadTimeout { get; set; }
Property Value Type Description int

A value, in milliseconds, that determines how long the stream will attempt to read before timing out.

Overrides Exceptions | Edit this page View Source WriteTimeout

Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.

Declaration
public override int WriteTimeout { get; set; }
Property Value Type Description int

A value, in milliseconds, that determines how long the stream will attempt to write before timing out.

Overrides Exceptions Methods | Edit this page View Source BeginRead(byte[], int, int, AsyncCallback?, object?)

Begins an asynchronous read operation. (Consider using ReadAsync(byte[], int, int) instead.)

Declaration
public override IAsyncResult BeginRead(byte[] data, int offset, int count, AsyncCallback? callback, object? state)
Parameters Type Name Description byte[] data int offset

The byte offset in buffer at which to begin writing data read from the stream.

int count

The maximum number of bytes to read.

AsyncCallback callback

An optional asynchronous callback, to be called when the read is complete.

object state

A user-provided object that distinguishes this particular asynchronous read request from other requests.

Returns Overrides Exceptions | Edit this page View Source BeginWrite(byte[], int, int, AsyncCallback?, object?)

Begins an asynchronous write operation. (Consider using WriteAsync(byte[], int, int) instead.)

Declaration
public override IAsyncResult BeginWrite(byte[] data, int offset, int count, AsyncCallback? callback, object? state)
Parameters Type Name Description byte[] data int offset

The byte offset in buffer from which to begin writing.

int count

The maximum number of bytes to write.

AsyncCallback callback

An optional asynchronous callback, to be called when the write is complete.

object state

A user-provided object that distinguishes this particular asynchronous write request from other requests.

Returns Type Description IAsyncResult

An IAsyncResult that represents the asynchronous write, which could still be pending.

Overrides Exceptions | Edit this page View Source CopyTo(Stream, int)

Reads the bytes from the current stream and writes them to another stream, using a specified buffer size. Both streams positions are advanced by the number of bytes copied.

Declaration
public override void CopyTo(Stream destination, int bufferSize)
Parameters Type Name Description Stream destination

The stream to which the contents of the current stream will be copied.

int bufferSize

The size of the buffer. This value must be greater than zero. The default size is 81920.

Overrides Exceptions | Edit this page View Source CopyToAsync(Stream, int, CancellationToken)

Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token. Both streams positions are advanced by the number of bytes copied.

Declaration
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken token)
Parameters Type Name Description Stream destination

The stream to which the contents of the current stream will be copied.

int bufferSize

The size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.

CancellationToken token Returns Type Description Task

A task that represents the asynchronous copy operation.

Overrides Exceptions | Edit this page View Source Dispose(bool)

Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

Declaration
protected override void Dispose(bool disposing)
Parameters Type Name Description bool disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Overrides | Edit this page View Source DisposeAsync()

Asynchronously releases the unmanaged resources used by the Stream.

Declaration
public override ValueTask DisposeAsync()
Returns Type Description ValueTask

A task that represents the asynchronous dispose operation.

Overrides | Edit this page View Source EndRead(IAsyncResult)

Waits for the pending asynchronous read to complete. (Consider using ReadAsync(byte[], int, int) instead.)

Declaration
public override int EndRead(IAsyncResult asyncResult)
Parameters Type Name Description IAsyncResult asyncResult

The reference to the pending asynchronous request to finish.

Returns Type Description int

The number of bytes read from the stream, between zero (0) and the number of bytes requested. ReadAsync returns zero (0) only if zero bytes were requested or if no more bytes will be available because it's at the end of the stream; otherwise, read operations do not complete until at least one byte is available. If zero bytes are requested, read operations may complete immediately or may not complete until at least one byte is available (but without consuming any data).

Overrides Exceptions | Edit this page View Source EndWrite(IAsyncResult)

Ends an asynchronous write operation. (Consider using WriteAsync(byte[], int, int) instead.)

Declaration
public override void EndWrite(IAsyncResult asyncResult)
Parameters Type Name Description IAsyncResult asyncResult

A reference to the outstanding asynchronous I/O request.

Overrides Exceptions | Edit this page View Source ~PoolingBufferedStream() Declaration
protected ~PoolingBufferedStream()
| Edit this page View Source Flush()

When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Declaration
public override void Flush()
Overrides Exceptions | Edit this page View Source FlushAsync(CancellationToken)

Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

Declaration
public override Task FlushAsync(CancellationToken token)
Parameters Returns Type Description Task

A task that represents the asynchronous flush operation.

Overrides Exceptions | Edit this page View Source Read()

Populates the internal buffer from the underlying stream.

Declaration Returns Exceptions | Edit this page View Source Read(byte[], int, int)

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public override int Read(byte[] data, int offset, int count)
Parameters Type Name Description byte[] data int offset

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

int count

The maximum number of bytes to be read from the current stream.

Returns Type Description int

The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if count is 0 or the end of the stream has been reached.

Overrides Exceptions | Edit this page View Source Read(Span<byte>)

When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public override int Read(Span<byte> data)
Parameters Returns Type Description int

The total number of bytes read into the buffer. This can be less than the size of the buffer if that many bytes are not currently available, or zero (0) if the buffer's length is zero or the end of the stream has been reached.

Overrides | Edit this page View Source ReadAsync(byte[], int, int, CancellationToken)

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

Declaration
public override Task<int> ReadAsync(byte[] data, int offset, int count, CancellationToken token)
Parameters Type Name Description byte[] data int offset

The byte offset in buffer at which to begin writing data from the stream.

int count

The maximum number of bytes to read.

CancellationToken token Returns Type Description Task<int>

A task that represents the asynchronous read operation. The value of the TResult parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if count is 0 or if the end of the stream has been reached.

Overrides Exceptions | Edit this page View Source ReadAsync(Memory<byte>, CancellationToken)

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

Declaration
public override ValueTask<int> ReadAsync(Memory<byte> data, CancellationToken token = default)
Parameters Returns Type Description ValueTask<int>

A task that represents the asynchronous read operation. The value of its Result property contains the total number of bytes read into the buffer. The result value can be less than the length of the buffer if that many bytes are not currently available, or it can be 0 (zero) if the length of the buffer is 0 or if the end of the stream has been reached.

Overrides | Edit this page View Source ReadAsync(CancellationToken)

Fetches the internal buffer from the underlying stream.

Declaration
public ValueTask<bool> ReadAsync(CancellationToken token = default)
Parameters Type Name Description CancellationToken token

The token that can be used to cancel the operation.

Returns Type Description ValueTask<bool>

true if the data has been copied from the file to the internal buffer; false if no more data to read.

Exceptions | Edit this page View Source ReadByte()

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Declaration
public override int ReadByte()
Returns Type Description int

The unsigned byte cast to an int, or -1 if at the end of the stream.

Overrides Exceptions | Edit this page View Source Reset()

Resets the internal buffer.

Declaration | Edit this page View Source Seek(long, SeekOrigin)

When overridden in a derived class, sets the position within the current stream.

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters Type Name Description long offset

A byte offset relative to the origin parameter.

SeekOrigin origin

A value of type SeekOrigin indicating the reference point used to obtain the new position.

Returns Type Description long

The new position within the current stream.

Overrides Exceptions | Edit this page View Source SetLength(long)

When overridden in a derived class, sets the length of the current stream.

Declaration
public override void SetLength(long value)
Parameters Type Name Description long value

The desired length of the current stream in bytes.

Overrides Exceptions | Edit this page View Source Write()

Writes the buffered data to the underlying stream.

Declaration | Edit this page View Source Write(byte[], int, int)

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Declaration
public override void Write(byte[] data, int offset, int count)
Parameters Type Name Description byte[] data int offset

The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

int count

The number of bytes to be written to the current stream.

Overrides Exceptions | Edit this page View Source Write(ReadOnlySpan<byte>)

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Declaration
public override void Write(ReadOnlySpan<byte> data)
Parameters Overrides | Edit this page View Source WriteAsync(byte[], int, int, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

Declaration
public override Task WriteAsync(byte[] data, int offset, int count, CancellationToken token)
Parameters Type Name Description byte[] data int offset

The zero-based byte offset in buffer from which to begin copying bytes to the stream.

int count

The maximum number of bytes to write.

CancellationToken token Returns Type Description Task

A task that represents the asynchronous write operation.

Overrides Exceptions | Edit this page View Source WriteAsync(ReadOnlyMemory<byte>, CancellationToken)

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

Declaration
public override ValueTask WriteAsync(ReadOnlyMemory<byte> data, CancellationToken token = default)
Parameters Returns Type Description ValueTask

A task that represents the asynchronous write operation.

Overrides | Edit this page View Source WriteAsync(CancellationToken)

Writes the buffered data to the underlying stream.

Declaration
public ValueTask WriteAsync(CancellationToken token = default)
Parameters Type Name Description CancellationToken token

The token that can be used to cancel the operation.

Returns Type Description ValueTask

The task representing asynchronous execution of the operation.

Exceptions | Edit this page View Source WriteByte(byte)

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

Declaration
public override void WriteByte(byte value)
Parameters Type Name Description byte value

The byte to write to the stream.

Overrides Exceptions Implements Extension Methods StreamExtensions.ParseAsync<TArg, TResult>(Stream, TArg, ReadOnlySpanFunc<char, TArg, TResult>, DecodingContext, LengthFormat, Memory<byte>, MemoryAllocator<char>?, CancellationToken)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4