V - 值public class BasePromise<V> extends Object implements Promise<V>
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
BasePromise.Done<V> |
protected static class |
BasePromise.Singleton |
static class |
BasePromise.Trans<R,V>
转换Promise为另一个Promise
|
protected static class |
BasePromise.Wrap<V> |
static class |
BasePromise.WrapException |
Promise.Listener<F extends Future<?>>| 限定符和类型 | 字段和说明 |
|---|---|
protected static Promise<?> |
_nil |
static int |
STATUS_CANCELLED |
static int |
STATUS_DONE |
static int |
STATUS_FAILED |
static int |
STATUS_PENDING |
| 构造器和说明 |
|---|
BasePromise() |
BasePromise(V value) |
| 限定符和类型 | 方法和说明 |
|---|---|
BasePromise<V> |
addListener(Promise.Listener<? extends Future<V>> listener)
添加监听器
|
void |
cancel()
取消
|
boolean |
cancel(boolean mayInterruptIfRunning) |
protected void |
cancel0(boolean mayInterruptIfRunning) |
boolean |
complete(V value)
处理完成,执行该方法后调用
isDone()总返回true |
static <V> Promise<V> |
done(V v) |
static <V> Promise<V> |
err(Throwable f) |
boolean |
fail(Throwable cause)
处理异常后结束,执行该方法后调用
isDone()总返回true |
protected void |
fail0(Throwable throwable) |
V |
get() |
V |
get(long timeout,
TimeUnit unit) |
Throwable |
getFailCause()
(若)失败的原因
|
V |
getValue() |
boolean |
isCancelled() |
boolean |
isDone() |
static <V> Promise<V> |
nil() |
protected static void |
notifyListener(Future future,
Promise.Listener listener) |
protected void |
notifyListeners(List<Promise.Listener<? extends Future<? super V>>> ls) |
protected void |
reset()
重置回初始状态
|
protected void |
setCause(Throwable cause) |
static <V> BasePromise<V> |
valueOf(Future<V> f) |
public static final int STATUS_FAILED
public static final int STATUS_DONE
public static final int STATUS_CANCELLED
public static final int STATUS_PENDING
protected static final Promise<?> _nil
public BasePromise()
public BasePromise(V value)
public static <V> BasePromise<V> valueOf(Future<V> f)
public static <V> Promise<V> done(V v)
public static <V> Promise<V> nil()
public boolean complete(V value)
isDone()总返回truevalue - 完成时的返回值public boolean fail(Throwable cause)
isDone()总返回truecause - 异常的原因protected void reset()
protected void setCause(Throwable cause)
public BasePromise<V> addListener(Promise.Listener<? extends Future<V>> listener)
PromiseaddListener 在接口中 Promise<V>listener - 要添加的监听器public boolean isCancelled()
isCancelled 在接口中 Future<V>public V get() throws InterruptedException, ExecutionException
get 在接口中 Future<V>InterruptedExceptionExecutionExceptionpublic Throwable getFailCause()
PromisegetFailCause 在接口中 Promise<V>public V getValue()
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get 在接口中 Future<V>InterruptedExceptionExecutionExceptionTimeoutExceptionpublic void cancel()
throws IllegalStateException,
UnsupportedOperationException
Cancelablecancel 在接口中 CancelableIllegalStateException - 状态不适合时UnsupportedOperationException - 操作不支持protected void fail0(Throwable throwable)
protected void cancel0(boolean mayInterruptIfRunning)
protected void notifyListeners(List<Promise.Listener<? extends Future<? super V>>> ls)
protected static void notifyListener(Future future, Promise.Listener listener)
Copyright © 2022. All rights reserved.