166 protected override void Dispose(
bool disposing)
170 if (disposing &&
_stream !=
null)
188 base.Dispose(disposing);
426 if (lastSyncCompletedReadTask !=
null && lastSyncCompletedReadTask.
Result == val)
428 return lastSyncCompletedReadTask;
445 if (
task.IsCompletedSuccessfully)
451 flag = num ==
count || error !=
null;
479 if (
task.IsCompletedSuccessfully)
485 flag = num ==
buffer.Length;
504 await semaphoreLockTask.
ConfigureAwait(continueOnCapturedContext:
false);
510 return bytesAlreadySatisfied + num;
515 bytesAlreadySatisfied += num;
529 return bytesAlreadySatisfied + num;
697 if (
task.IsCompletedSuccessfully)
726 await semaphoreLockTask.
ConfigureAwait(continueOnCapturedContext:
false);
823 long num2 = num - (position -
_readPos);
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
int ReadFromBuffer(byte[] buffer, int offset, int count, out Exception error)
BufferedStream(Stream stream)
override void Dispose(bool disposing)
override int EndRead(IAsyncResult asyncResult)
override int Read(Span< byte > destination)
override async ValueTask DisposeAsync()
Task< int > _lastSyncCompletedReadTask
Task< int > LastSyncCompletedReadTask(int val)
async Task CopyToAsyncCore(Stream destination, int bufferSize, CancellationToken cancellationToken)
BufferedStream(Stream stream, int bufferSize)
override void Write(ReadOnlySpan< byte > buffer)
override void EndWrite(IAsyncResult asyncResult)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
override Task FlushAsync(CancellationToken cancellationToken)
void WriteByteSlow(byte value)
int WriteToBuffer(ReadOnlySpan< byte > buffer)
override void Write(byte[] buffer, int offset, int count)
override void SetLength(long value)
void WriteToBuffer(byte[] buffer, ref int offset, ref int count)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
void EnsureBufferAllocated()
override void CopyTo(Stream destination, int bufferSize)
void ClearReadBufferBeforeWrite()
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
async Task FlushAsyncInternal(CancellationToken cancellationToken)
override long Seek(long offset, SeekOrigin origin)
async ValueTask FlushWriteAsync(CancellationToken cancellationToken)
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
void EnsureShadowBufferAllocated()
override void WriteByte(byte value)
async ValueTask WriteToUnderlyingStreamAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken, Task semaphoreLockTask)
int ReadFromBuffer(Span< byte > destination)
int ReadFromBuffer(byte[] buffer, int offset, int count)
override int Read(byte[] buffer, int offset, int count)
async ValueTask< int > ReadFromUnderlyingStreamAsync(Memory< byte > buffer, CancellationToken cancellationToken, int bytesAlreadySatisfied, Task semaphoreLockTask)
static void ValidateBufferArguments(byte[] buffer, int offset, int count)
void SetLength(long value)
long Seek(long offset, SeekOrigin origin)
static void ValidateCopyToArguments(Stream destination, int bufferSize)
Task WriteAsync(byte[] buffer, int offset, int count)
int Read(byte[] buffer, int offset, int count)
void CopyTo(Stream destination)
Task< int > ReadAsync(byte[] buffer, int offset, int count)
SemaphoreSlim _asyncActiveSemaphore
void Write(byte[] buffer, int offset, int count)
Task CopyToAsync(Stream destination)
SemaphoreSlim EnsureAsyncActiveSemaphoreInitialized()
virtual ValueTask DisposeAsync()
static byte Min(byte val1, byte val2)
static string Format(string resourceFormat, object p1)
static string ArgumentOutOfRange_MustBePositive
static string NotSupported_CannotWriteToBufferedStreamIfReadBufferCannotBeFlushed
static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
static void End(IAsyncResult asyncResult)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
static Task FromException(Exception exception)
static Task FromCanceled(CancellationToken cancellationToken)
static void ThrowNotSupportedException_UnwritableStream()
static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
static void ThrowNotSupportedException_UnseekableStream()
static void ThrowArgumentNullException(string name)
static void ThrowObjectDisposedException_StreamClosed(string objectName)
static void ThrowNotSupportedException_UnreadableStream()
void CopyTo(Span< T > destination)
static CancellationToken None
static ValueTask FromCanceled(CancellationToken cancellationToken)
ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)