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>
,Runnable
,Future<V>
,RunnableFuture<V>
- Direct Known Subclasses:
ScheduledFutureTask
,UnorderedThreadPoolEventExecutor.RunnableScheduledFutureTask
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static class
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Runnable
private static final Runnable
private static final Runnable
private Object
Fields inherited from class io.netty.util.concurrent.DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTH
-
Constructor Summary
ConstructorsConstructorDescriptionPromiseTask
(EventExecutor executor, Runnable runnable) PromiseTask
(EventExecutor executor, Runnable runnable, V result) PromiseTask
(EventExecutor executor, Callable<V> callable) -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) If the cancellation was successful it will fail the future with aCancellationException
.private boolean
clearTaskAfterCompletion
(boolean done, Runnable result) final boolean
final int
hashCode()
void
run()
(package private) V
runTask()
setFailure
(Throwable cause) Marks this future as a failure and notifies all listeners.setFailureInternal
(Throwable cause) setSuccess
(V result) Marks this future as a success and notifies all listeners.setSuccessInternal
(V result) final boolean
Make this future impossible to cancel.protected final boolean
protected StringBuilder
final boolean
tryFailure
(Throwable cause) Marks this future as a failure and notifies all listeners.protected final boolean
tryFailureInternal
(Throwable cause) final boolean
trySuccess
(V result) Marks this future as a success and notifies all listeners.protected final boolean
trySuccessInternal
(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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.concurrent.Future
exceptionNow, get, get, isCancelled, isDone, resultNow, state
-
Field Details
-
COMPLETED
-
CANCELLED
-
FAILED
-
task
-
-
Constructor Details
-
PromiseTask
PromiseTask(EventExecutor executor, Runnable runnable, V result) -
PromiseTask
PromiseTask(EventExecutor executor, Runnable runnable) -
PromiseTask
PromiseTask(EventExecutor executor, Callable<V> callable)
-
-
Method Details
-
hashCode
public final int hashCode() -
equals
-
runTask
- Throws:
Throwable
-
run
public void run()- Specified by:
run
in interfaceRunnable
- Specified by:
run
in interfaceRunnableFuture<V>
-
clearTaskAfterCompletion
-
setFailure
Description copied from interface:Promise
Marks this future as a failure and notifies all listeners. If it is success or failed already it will throw anIllegalStateException
.- Specified by:
setFailure
in interfacePromise<V>
- Overrides:
setFailure
in classDefaultPromise<V>
-
setFailureInternal
-
tryFailure
Description copied from interface:Promise
Marks this future as a failure and notifies all listeners.- Specified by:
tryFailure
in interfacePromise<V>
- Overrides:
tryFailure
in classDefaultPromise<V>
- Returns:
true
if and only if successfully marked this future as a failure. Otherwisefalse
because this future is already marked as either a success or a failure.
-
tryFailureInternal
-
setSuccess
Description copied from interface:Promise
Marks this future as a success and notifies all listeners. If it is success or failed already it will throw anIllegalStateException
.- Specified by:
setSuccess
in interfacePromise<V>
- Overrides:
setSuccess
in classDefaultPromise<V>
-
setSuccessInternal
-
trySuccess
Description copied from interface:Promise
Marks this future as a success and notifies all listeners.- Specified by:
trySuccess
in interfacePromise<V>
- Overrides:
trySuccess
in classDefaultPromise<V>
- Returns:
true
if and only if successfully marked this future as a success. Otherwisefalse
because this future is already marked as either a success or a failure.
-
trySuccessInternal
-
setUncancellable
public final boolean setUncancellable()Description copied from interface:Promise
Make this future impossible to cancel.- Specified by:
setUncancellable
in interfacePromise<V>
- Overrides:
setUncancellable
in classDefaultPromise<V>
- Returns:
true
if and only if successfully marked this future as uncancellable or it is already done without being cancelled.false
if this future has been cancelled already.
-
setUncancellableInternal
protected final boolean setUncancellableInternal() -
cancel
public boolean cancel(boolean mayInterruptIfRunning) Description copied from class:DefaultPromise
If the cancellation was successful it will fail the future with aCancellationException
. -
toStringBuilder
- Overrides:
toStringBuilder
in classDefaultPromise<V>
-