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 class
PromiseTask.RunnableAdapter<T>
private static class
PromiseTask.SentinelRunnable
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Runnable
CANCELLED
private static java.lang.Runnable
COMPLETED
private static java.lang.Runnable
FAILED
private java.lang.Object
task
-
Fields inherited from class io.netty.util.concurrent.DefaultPromise
PROPERTY_MAX_LISTENER_STACK_DEPTH
-
-
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 boolean
cancel(boolean mayInterruptIfRunning)
If the cancellation was successful it will fail the future with aCancellationException
.private boolean
clearTaskAfterCompletion(boolean done, java.lang.Runnable result)
boolean
equals(java.lang.Object obj)
int
hashCode()
void
run()
(package private) V
runTask()
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)
boolean
setUncancellable()
Make this future impossible to cancel.protected boolean
setUncancellableInternal()
protected java.lang.StringBuilder
toStringBuilder()
boolean
tryFailure(java.lang.Throwable cause)
Marks this future as a failure and notifies all listeners.protected boolean
tryFailureInternal(java.lang.Throwable cause)
boolean
trySuccess(V result)
Marks this future as a success and notifies all listeners.protected 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
-
-
-
-
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:
hashCode
in classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
runTask
V runTask() throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Specified by:
run
in 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: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>
-
tryFailure
public final boolean tryFailure(java.lang.Throwable cause)
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
protected final boolean tryFailureInternal(java.lang.Throwable cause)
-
setSuccess
public final Promise<V> setSuccess(V result)
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>
-
trySuccess
public final boolean trySuccess(V result)
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
protected final boolean trySuccessInternal(V result)
-
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
protected java.lang.StringBuilder toStringBuilder()
- Overrides:
toStringBuilder
in classDefaultPromise<V>
-
-