package netty.test;
/**
* @Author:chaoqiang.zhou
* @Description:
* @Date:Create in 15:10 2017/10/19
*/import io.netty.util.concurrent.GenericFutureListener;
/**
* Future中的一个特别的可写入的获取结果
*/
public interface Promise<V> extends io.netty.util.concurrent.Future<V> {
/**
* Marks this future as a success and notifies all
* listeners.
* <p>
* If it is success or failed already it will throw an {@link IllegalStateException}.
*//**
* 标记future为成功,并且通知所有的listener
* 如果已经是成功或者异常的话,会抛出IllegalStateException
* @param result
* @return
*/
Promise<V> setSuccess(V result);
/**
* Marks this future as a success and notifies all
* listeners.
*
* @return {@code true} if and only if successfully marked this future as
* a success. Otherwise {@code false} because this future is
* already marked as either a success or a failure.
*//**
* 标记future为成功,并且通知所有的listener
* 如果已经是成功或者异常的话,会抛出IllegalStateException
* 仅仅当成功的标记为true时,才返回true,否则的话,就返回false
* @param result
* @return
*/
boolean trySuccess(V result);
/**
* 与标记成功类似
* @param cause
* @return
*/
Promise<V> setFailure(Throwable cause);
boolean tryFailure(Throwable cause);
/**
* Make this future impossible to cancel.
*
* @return {@code true} if and only if successfully marked this future as uncancellable or it is already done
* without being cancelled. {@code false} if this future has been cancelled already.
*//**
* 标记该future为不可以被cancle
* 只有当标记成功,或者之前已经被标记过后才返回true
* @return
*/
boolean setUncancellable();
@Override
Promise<V> addListener(GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener);
@Override
Promise<V> addListeners(GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>>... listeners);
@Override
Promise<V> removeListener(GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>> listener);
@Override
Promise<V> removeListeners(GenericFutureListener<? extends io.netty.util.concurrent.Future<? super V>>... listeners);
@Override
Promise<V> await() throws InterruptedException;
@Override
Promise<V> awaitUninterruptibly();
@Override
Promise<V> sync() throws InterruptedException;
@Override
Promise<V> syncUninterruptibly();