public IWritableChannel MakeWriteableChannel(IWritableChannel channel, Func <IReadableChannel, IWritableChannel, Task> consume) { var newChannel = new MemoryPoolChannel(_pool); consume(newChannel, channel).ContinueWith(t => { }); return(newChannel); }
internal WritableBuffer(MemoryPoolChannel channel, MemoryPool pool, MemoryBlockSegment segment) { _channel = channel; _pool = pool; _tail = segment; _tailIndex = segment?.End ?? 0; _head = segment; _headIndex = _tailIndex; }
public IReadableChannel MakeReadableChannel(IReadableChannel channel, Func <IReadableChannel, IWritableChannel, Task> produce) { var newChannel = new MemoryPoolChannel(_pool); // TODO: Avoid closure newChannel.OnStartReading(() => { produce(channel, newChannel).ContinueWith(t => { }); }); return(newChannel); }
internal ReadableBuffer(MemoryPoolChannel channel, ReadCursor start, ReadCursor end, bool isOwner) { _channel = channel; _start = start; _end = end; _isOwner = isOwner; _disposed = false; var begin = start; begin.TryGetBuffer(end, out _span); begin = start; _length = begin.GetLength(end); }
public IWritableChannel MakeWriteableChannel(Stream stream) { if (!stream.CanWrite) { throw new InvalidOperationException(); } var channel = new MemoryPoolChannel(_pool); channel.CopyToAsync(stream).ContinueWith((task) => { channel.CompleteReading(); }); return(channel); }
public IWritableChannel CreateWritableChannel(Stream stream) { if (!stream.CanWrite) { throw new InvalidOperationException(); } var channel = new MemoryPoolChannel(_pool); channel.CopyToAsync(stream).ContinueWith((task, state) => { ((Stream)state).Dispose(); }, stream); return(channel); }
public IReadableChannel MakeReadableChannel(Stream stream) { if (!stream.CanRead) { throw new InvalidOperationException(); } var channel = new MemoryPoolChannel(_pool); channel.OnStartReading(() => { stream.CopyToAsync(channel).ContinueWith(task => { }); }); return(channel); }
public ReadableChannel(MemoryPool pool) { _channel = new MemoryPoolChannel(pool); }
internal ReadableBuffer(MemoryPoolChannel channel, ReadCursor start, ReadCursor end) : this(channel, start, end, isOwner : false) { }