[#2752] Add PendingWriteQueue for queue up writes

Motivation:

Sometimes ChannelHandler need to queue writes to some point and then process these. We currently have no datastructure for this so the user will use an Queue or something like this. The problem is with this Channel.isWritable() will not work as expected and so the user risk to write to fast. That's exactly what happened in our SslHandler. For this purpose we need to add a special datastructure which will also take care of update the Channel and so be sure that Channel.isWritable() works as expected.

Modifications:

- Add PendingWriteQueue which can be used for this purpose
- Make use of PendingWriteQueue in SslHandler

Result:

It is now possible to queue writes in a ChannelHandler and still have Channel.isWritable() working as expected. This also fixes #2752.
Did this to elimate method call if assert is not enabled

> Am 11.08.2014 um 20:33 schrieb Trustin Lee <notifications@github.com>:
> 
> In transport/src/main/java/io/netty/channel/PendingWriteQueue.java:
> 
> > +        ChannelPromiseAggregator aggregator = new ChannelPromiseAggregator(p);
> > +        while (write != null) {
> > +            PendingWrite next = write.next;
> > +            Object msg = write.msg;
> > +            ChannelPromise promise = write.promise;
> > +            recycle(write);
> > +            ctx.write(msg, promise);
> > +            aggregator.add(promise);
> > +            write = next;
> > +        }
> > +        assert assertEmpty();
> > +        return p;
> > +    }
> > +
> > +    private boolean assertEmpty() {
> > +        return tail == null && head == null && size == 0;
> s/return/assert/ for simplicity
> 
> —
> Reply to this email directly or view it on GitHub.