class MessageGate extends ChannelDuplexHandler {

    @Override
    public void userEventTriggered( ChannelHandlerContext ctx, Object evt ) throws Exception
    {
        if ( evt instanceof GateEvent )
        {
            if ( GateEvent.getSuccess().equals( evt ) )
            {
                for ( GatedWrite write : pending )
                {
                    ctx.write( write.msg, write.promise );
                }

                ctx.channel().pipeline().remove( this );
            }

            pending.clear();
            pending = null;
        }
        else
        {
            super.userEventTriggered( ctx, evt );
        }
    }

    public  MessageGate( Predicate<Object> gated );

}