Class PromiseTask<V>
java.lang.Object
io.netty.util.concurrent.AbstractFuture<V>
io.netty.util.concurrent.DefaultPromise<V>
io.netty.util.concurrent.PromiseTask<V>
- All Implemented Interfaces:
Future<V>, Promise<V>, java.lang.Runnable, java.util.concurrent.Future<V>, java.util.concurrent.RunnableFuture<V>
- Direct Known Subclasses:
ScheduledFutureTask, UnorderedThreadPoolEventExecutor.RunnableScheduledFutureTask
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final java.lang.Runnableprivate static final java.lang.Runnableprivate static final java.lang.Runnableprivate java.lang.ObjectFields inherited from class DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTH -
Constructor Summary
ConstructorsConstructorDescriptionPromiseTask(EventExecutor executor, java.lang.Runnable runnable) PromiseTask(EventExecutor executor, java.lang.Runnable runnable, V result) PromiseTask(EventExecutor executor, java.util.concurrent.Callable<V> callable) -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException.private booleanclearTaskAfterCompletion(boolean done, java.lang.Runnable result) final booleanequals(java.lang.Object obj) final inthashCode()voidrun()(package private) VrunTask()setFailure(java.lang.Throwable cause) Marks this future as a failure and notifies all listeners.setFailureInternal(java.lang.Throwable cause) setSuccess(V result) Marks this future as a success and notifies all listeners.setSuccessInternal(V result) final booleanMake this future impossible to cancel.protected final booleanprotected java.lang.StringBuilderfinal booleantryFailure(java.lang.Throwable cause) Marks this future as a failure and notifies all listeners.protected final booleantryFailureInternal(java.lang.Throwable cause) final booleantrySuccess(V result) Marks this future as a success and notifies all listeners.protected final booleantrySuccessInternal(V result) Methods inherited from class DefaultPromise
addListener, addListeners, await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, cause, checkDeadLock, executor, get, get, getNow, isCancellable, isCancelled, isDone, isSuccess, notifyListener, notifyProgressiveListeners, removeListener, removeListeners, sync, syncUninterruptibly, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
get, get, isCancelled, isDone
-
Field Details
-
COMPLETED
private static final java.lang.Runnable COMPLETED -
CANCELLED
private static final java.lang.Runnable CANCELLED -
FAILED
private static final java.lang.Runnable FAILED -
task
private java.lang.Object task
-
-
Constructor Details
-
PromiseTask
PromiseTask(EventExecutor executor, java.lang.Runnable runnable, V result) -
PromiseTask
PromiseTask(EventExecutor executor, java.lang.Runnable runnable) -
PromiseTask
PromiseTask(EventExecutor executor, java.util.concurrent.Callable<V> callable)
-
-
Method Details
-
hashCode
public final int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj) - Overrides:
equalsin classjava.lang.Object
-
runTask
- Throws:
java.lang.Throwable
-
run
public void run()- Specified by:
runin interfacejava.lang.Runnable- Specified by:
runin interfacejava.util.concurrent.RunnableFuture<V>
-
clearTaskAfterCompletion
private boolean clearTaskAfterCompletion(boolean done, java.lang.Runnable result) -
setFailure
Description copied from interface:PromiseMarks this future as a failure and notifies all listeners. If it is success or failed already it will throw anIllegalStateException.- Specified by:
setFailurein interfacePromise<V>- Overrides:
setFailurein classDefaultPromise<V>
-
setFailureInternal
-
tryFailure
public final boolean tryFailure(java.lang.Throwable cause) Description copied from interface:PromiseMarks this future as a failure and notifies all listeners.- Specified by:
tryFailurein interfacePromise<V>- Overrides:
tryFailurein classDefaultPromise<V>- Returns:
trueif and only if successfully marked this future as a failure. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
tryFailureInternal
protected final boolean tryFailureInternal(java.lang.Throwable cause) -
setSuccess
Description copied from interface:PromiseMarks this future as a success and notifies all listeners. If it is success or failed already it will throw anIllegalStateException.- Specified by:
setSuccessin interfacePromise<V>- Overrides:
setSuccessin classDefaultPromise<V>
-
setSuccessInternal
-
trySuccess
Description copied from interface:PromiseMarks this future as a success and notifies all listeners.- Specified by:
trySuccessin interfacePromise<V>- Overrides:
trySuccessin classDefaultPromise<V>- Returns:
trueif and only if successfully marked this future as a success. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
trySuccessInternal
-
setUncancellable
public final boolean setUncancellable()Description copied from interface:PromiseMake this future impossible to cancel.- Specified by:
setUncancellablein interfacePromise<V>- Overrides:
setUncancellablein classDefaultPromise<V>- Returns:
trueif and only if successfully marked this future as uncancellable or it is already done without being cancelled.falseif this future has been cancelled already.
-
setUncancellableInternal
protected final boolean setUncancellableInternal() -
cancel
public boolean cancel(boolean mayInterruptIfRunning) Description copied from class:DefaultPromiseIf the cancellation was successful it will fail the future with aCancellationException. -
toStringBuilder
protected java.lang.StringBuilder toStringBuilder()- Overrides:
toStringBuilderin classDefaultPromise<V>
-