Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (39 sloc) 2.22 KB
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Sources;
namespace System.IO.Pipelines
{
/// <summary>
/// Default <see cref="PipeWriter"/> and <see cref="PipeReader"/> implementation.
/// </summary>
public sealed partial class Pipe
{
private sealed class DefaultPipeWriter : PipeWriter, IValueTaskSource<FlushResult>
{
private readonly Pipe _pipe;
public DefaultPipeWriter(Pipe pipe)
{
_pipe = pipe;
}
public override void Complete(Exception exception = null) => _pipe.CompleteWriter(exception);
public override void CancelPendingFlush() => _pipe.CancelPendingFlush();
#pragma warning disable CS0672 // Member overrides obsolete member
public override void OnReaderCompleted(Action<Exception, object> callback, object state) => _pipe.OnReaderCompleted(callback, state);
#pragma warning restore CS0672 // Member overrides obsolete member
public override ValueTask<FlushResult> FlushAsync(CancellationToken cancellationToken = default) => _pipe.FlushAsync(cancellationToken);
public override void Advance(int bytes) => _pipe.Advance(bytes);
public override Memory<byte> GetMemory(int sizeHint = 0) => _pipe.GetMemory(sizeHint);
public override Span<byte> GetSpan(int sizeHint = 0) => _pipe.GetSpan(sizeHint);
public ValueTaskSourceStatus GetStatus(short token) => _pipe.GetFlushAsyncStatus();
public FlushResult GetResult(short token) => _pipe.GetFlushAsyncResult();
public void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags) => _pipe.OnFlushAsyncCompleted(continuation, state, flags);
public override ValueTask<FlushResult> WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default)
{
return _pipe.WriteAsync(source, cancellationToken);
}
}
}
}
You can’t perform that action at this time.