public FlowControlledData(DefaultHttp2ConnectionEncoder encoder,
                           IHttp2Stream stream, IByteBuffer buf, int padding, bool endOfStream, IPromise promise, IChannel channel)
     : base(encoder, stream, padding, endOfStream, promise)
 {
     _queue = new CoalescingBufferQueue(channel);
     _queue.Add(buf, promise);
     _dataSize = _queue.ReadableBytes();
 }
        public CoalescingBufferQueueTest()
        {
            this.mouseDone    = false;
            this.mouseSuccess = false;
            this.channel      = new EmbeddedChannel();
            this.writeQueue   = new CoalescingBufferQueue(channel, 16, true);
            this.catPromise   = new DefaultPromise();
            //    mouseListener = new ChannelFutureListener() {
            //    @Override
            //    public void operationComplete(ChannelFuture future) throws Exception {
            //        mouseDone = true;
            //        mouseSuccess = future.IsSuccess();
            //    }
            //};
            this.emptyPromise = channel.NewPromise();
            this.voidPromise  = channel.VoidPromise();

            this.cat   = Unpooled.WrappedBuffer(Encoding.ASCII.GetBytes("cat"));
            this.mouse = Unpooled.WrappedBuffer(Encoding.ASCII.GetBytes("mouse"));
        }
        public void Merge()
        {
            writeQueue.Add(cat, catPromise);
            CoalescingBufferQueue otherQueue = new CoalescingBufferQueue(channel);

            otherQueue.Add(mouse, NewFutureListener());
            otherQueue.CopyTo(writeQueue);
            AssertQueueSize(8, false);
            IPromise aggregatePromise = NewPromise();

            Assert.Equal("catmouse", Dequeue(8, aggregatePromise));
            AssertQueueSize(0, true);
            Assert.False(catPromise.IsSuccess);
            Assert.False(mouseDone);
            aggregatePromise.Complete();
            Assert.True(catPromise.IsSuccess);
            Assert.True(mouseSuccess);
            Assert.Equal(0, cat.ReferenceCount);
            Assert.Equal(0, mouse.ReferenceCount);
        }