1、Future与ChannelFuture
Future未来(期望),Netty事件都是异步
Future的get方法是阻塞,Netty对JDK的Future进行异步的封装,如:判断状态isSuccess方法(成功或失败状态)改良点
ChannelFuture是Future的特化,维护了一个Channel对象
ChannelPromise(复合管道)是ChannelFuture的子类
V get() 读取数据
ChannelPromise复合管道
public interface Future extends java.util.concurrent.Future {
boolean isSuccess(); //当且仅当i/o操作成功完成时,返回true
boolean isCancellable(); //当且仅当可以通过cancel方法取消时,返回true
Throwable cause();//如果i/o操作失败,返回其失败原因。如果成功完成或者还未完成,返回null
//将指定的监听器添加到此Future,future完成时,会通知此监听器,如果添加监听器时future已经完成,则立即通知此监听器
Future addListener(GenericFutureListener extends Future super V>> listener);
//移除监听器,如果future已经完成,则不会触发
Future removeListener(GenericFutureListener extends Future super V>> listener);
//等待此future done
Future sync() throws InterruptedException;
//等待,不可中断
Future syncUninterruptibly();
//等待Future完成
Future await() throws InterruptedException;
//等待Future完成,不可中断
Future awaitUninterruptibly();
//立即返回,如果此时fu