Package io.netty.util.concurrent
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
class PromiseTask<V> extends DefaultPromise<V> implements java.util.concurrent.RunnableFuture<V>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPromiseTask.RunnableAdapter<T>private static classPromiseTask.SentinelRunnable
-
Constructor Summary
Constructors Constructor Description PromiseTask(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)If the cancellation was successful it will fail the future with aCancellationException.private booleanclearTaskAfterCompletion(boolean done, java.lang.Runnable result)booleanequals(java.lang.Object obj)inthashCode()voidrun()(package private) VrunTask()Promise<V>setFailure(java.lang.Throwable cause)Marks this future as a failure and notifies all listeners.protected Promise<V>setFailureInternal(java.lang.Throwable cause)Promise<V>setSuccess(V result)Marks this future as a success and notifies all listeners.protected Promise<V>setSuccessInternal(V result)booleansetUncancellable()Make this future impossible to cancel.protected booleansetUncancellableInternal()protected java.lang.StringBuildertoStringBuilder()booleantryFailure(java.lang.Throwable cause)Marks this future as a failure and notifies all listeners.protected booleantryFailureInternal(java.lang.Throwable cause)booleantrySuccess(V result)Marks this future as a success and notifies all listeners.protected booleantrySuccessInternal(V result)-
Methods inherited from class io.netty.util.concurrent.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, toString
-
-
-
-
Constructor Detail
-
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 Detail
-
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
final V runTask() throws java.lang.Exception
- Throws:
java.lang.Exception
-
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
public final Promise<V> setFailure(java.lang.Throwable cause)
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>
-
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
public final Promise<V> setSuccess(V result)
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>
-
trySuccess
public final boolean trySuccess(V result)
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
protected final boolean trySuccessInternal(V result)
-
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>
-
-