public void TestRemoveAndWriteAllReentrantWrite() { EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter0(), new ChannelHandlerAdapter()); PendingWriteQueue queue = new PendingWriteQueue(channel.Pipeline.LastContext()); IPromise promise = channel.NewPromise(); IPromise promise3 = channel.NewPromise(); promise.Task.ContinueWith(t => queue.Add(3L, promise3), TaskContinuationOptions.ExecuteSynchronously); queue.Add(1L, promise); IPromise promise2 = channel.NewPromise(); queue.Add(2L, promise2); queue.RemoveAndWriteAllAsync(); Assert.True(promise.IsCompleted); Assert.True(promise.IsSuccess); Assert.True(promise2.IsCompleted); Assert.True(promise2.IsSuccess); Assert.True(promise3.IsCompleted); Assert.True(promise3.IsSuccess); Assert.True(channel.Finish()); Assert.Equal(1L, channel.ReadOutbound <long>()); Assert.Equal(2L, channel.ReadOutbound <long>()); Assert.Equal(3L, channel.ReadOutbound <long>()); }
private void WritePendingWrites() { if (_pendingWrites != null) { _pendingWrites.RemoveAndWriteAllAsync(); _pendingWrites = null; } }
private static void AssertQueueEmpty(PendingWriteQueue queue) { Assert.True(queue.IsEmpty); Assert.Equal(0, queue.Size); Assert.Equal(0, queue.Bytes); Assert.Null(queue.Current); Assert.Null(queue.RemoveAndWriteAsync()); Assert.Null(queue.RemoveAndWriteAllAsync()); }
public void TestRemoveAndWriteAllReentrance() { EmbeddedChannel channel = NewChannel(); PendingWriteQueue queue = new PendingWriteQueue(channel.Pipeline.FirstContext()); IPromise promise = channel.NewPromise(); promise.Task.ContinueWith(t => queue.RemoveAndWriteAllAsync(), TaskContinuationOptions.ExecuteSynchronously); queue.Add(1L, promise); IPromise promise2 = channel.NewPromise(); queue.Add(2L, promise2); queue.RemoveAndWriteAllAsync(); channel.Flush(); Assert.True(promise.IsSuccess); Assert.True(promise2.IsSuccess); Assert.True(channel.Finish()); Assert.Equal(1L, channel.ReadOutbound <long>()); Assert.Equal(2L, channel.ReadOutbound <long>()); Assert.Null(channel.ReadOutbound()); Assert.Null(channel.ReadOutbound()); }
public void TestRemoveAndWriteAllWithVoidPromise() { EmbeddedChannel channel = new EmbeddedChannel(new ChannelOutboundHandlerAdapter0(), new ChannelHandlerAdapter()); PendingWriteQueue queue = new PendingWriteQueue(channel.Pipeline.LastContext()); IPromise promise = channel.NewPromise(); queue.Add(1L, promise); queue.Add(2L, channel.VoidPromise()); queue.RemoveAndWriteAllAsync(); Assert.True(channel.Finish()); Assert.True(promise.IsCompleted); Assert.True(promise.IsSuccess); Assert.Equal(1L, channel.ReadOutbound <long>()); Assert.Equal(2L, channel.ReadOutbound <long>()); }