Top Inners Fields Constructors Methods
io.netty.util.concurrent

public Class DefaultPromise<V>

extends AbstractFuture<V>
implements Promise<V>
Class Inheritance
All Implemented Interfaces
io.netty.util.concurrent.Promise, io.netty.util.concurrent.Future, java.util.concurrent.Future
Known Direct Subclasses
io.netty.util.concurrent.ImmediateEventExecutor.ImmediatePromise, io.netty.util.concurrent.PromiseTask, io.netty.util.concurrent.DefaultProgressivePromise
Imports
io.netty.util.internal.InternalThreadLocalMap, .PlatformDependent, .StringUtil, .SystemPropertyUtil, .ThrowableUtil, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.util.concurrent.CancellationException, .ExecutionException, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicReferenceFieldUpdater

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final DefaultPromise.CauseHolder
private static final StackTraceElement[]
private final EventExecutor
private GenericFutureListener<? extends Future<?>>
listener

One or more listeners.

private DefaultFutureListeners
private static final InternalLogger
private static final int
private boolean
notifyingListeners

Threading - synchronized(this).

private static final InternalLogger
private volatile Object
private static final AtomicReferenceFieldUpdater<DefaultPromise<V>, Object>
private static final Object
private static final Object
private short
waiters

Threading - synchronized(this).

Constructor Summary

AccessConstructor and Description
public
DefaultPromise(EventExecutor
the EventExecutor which is used to notify the promise once it is complete. It is assumed this executor will protect against StackOverflowError exceptions. The executor may be used to avoid StackOverflowError by executing a Runnable if the stack depth exceeds a threshold.
executor
)

Creates a new instance.

protected
DefaultPromise()

See executor() for expectations of the executor.

Method Summary

Modifier and TypeMethod and Description
public Promise<V>
addListener(GenericFutureListener<? extends Future<? super V>> listener)

Implements io.netty.util.concurrent.Promise.addListener, io.netty.util.concurrent.Future.addListener.

Adds the specified listener to this future.
private void
addListener0(GenericFutureListener<? extends Future<? super V>> listener)

public Promise<V>
addListeners(GenericFutureListener<? extends Future<? super V>>... listeners)

Implements io.netty.util.concurrent.Promise.addListeners, io.netty.util.concurrent.Future.addListeners.

Adds the specified listeners to this future.
public Promise<V>
await()

Implements io.netty.util.concurrent.Promise.await, io.netty.util.concurrent.Future.await.

Waits for this future to be completed.
public boolean
await(long timeout, TimeUnit unit)

Implements io.netty.util.concurrent.Future.await.

Waits for this future to be completed within the specified time limit.
public boolean
await(long timeoutMillis)

Implements io.netty.util.concurrent.Future.await.

Waits for this future to be completed within the specified time limit.
private boolean
await0(long timeoutNanos, boolean interruptable)

public Promise<V>
public boolean
awaitUninterruptibly(long timeout, TimeUnit unit)

Implements io.netty.util.concurrent.Future.awaitUninterruptibly.

Waits for this future to be completed within the specified time limit without interruption.
public boolean
awaitUninterruptibly(long timeoutMillis)

Implements io.netty.util.concurrent.Future.awaitUninterruptibly.

Waits for this future to be completed within the specified time limit without interruption.
public boolean
cancel(boolean
this value has no effect in this implementation.
mayInterruptIfRunning
)

Implements io.netty.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.
public Throwable
cause()

Implements io.netty.util.concurrent.Future.cause.

Returns the cause of the failed I/O operation if the I/O operation has failed.
private Throwable
cause0(Object result)

protected void
private synchronized boolean

Returns:

true if there are any listeners attached to the promise, false otherwise.
checkNotifyWaiters
()

Check if there are any waiters and if so notify these.

private void
protected EventExecutor

Returns:

The executor used to notify listeners when this promise is complete.
executor
()

Get the executor used to notify listeners when this promise is complete.

public V
get()

Overrides io.netty.util.concurrent.AbstractFuture.get.

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.
public V
get(long
the maximum time to wait
timeout
,
TimeUnit
the time unit of the timeout argument
unit
)

Overrides io.netty.util.concurrent.AbstractFuture.get.

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.
public V
getNow()

Implements io.netty.util.concurrent.Future.getNow.

Return the result without blocking.
private void
public boolean
isCancellable()

Implements io.netty.util.concurrent.Future.isCancellable.

returns true if and only if the operation can be cancelled via cancel(boolean).
public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.
private static boolean
public boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.
private static boolean
isDone0(Object result)

public boolean
isSuccess()

Implements io.netty.util.concurrent.Future.isSuccess.

Returns true if and only if the I/O operation was completed successfully.
protected static void
notifyListener(EventExecutor
the executor to use to notify the listener listener.
eventExecutor
,
final Future<?>
the future that is complete.
future
,
final GenericFutureListener<?>
the listener to notify.
listener
)

Notify a listener that a future has completed.

private static void
notifyListener0(Future<V> future, GenericFutureListener<F extends Future<?>> l)

private void
private void
private void
private static void
notifyListenerWithStackOverFlowProtection(final EventExecutor executor, final Future<?> future, final GenericFutureListener<?> listener)

The logic in this method should be identical to notifyListeners() but cannot share code because the listener(s) cannot be cached for an instance of DefaultPromise since the listener(s) may be changed and is protected by a synchronized operation.

private static void
pack-priv void
notifyProgressiveListeners(final long
the new progress.
progress
,
final long
the total progress.
total
)

Notify all progressive listeners.

private static void
notifyProgressiveListeners0(ProgressiveFuture<?> future, GenericProgressiveFutureListener<?>[] listeners, long progress, long total)

private synchronized Object
public Promise<V>
removeListener(final GenericFutureListener<? extends Future<? super V>> listener)

Implements io.netty.util.concurrent.Promise.removeListener, io.netty.util.concurrent.Future.removeListener.

Removes the first occurrence of the specified listener from this future.
private void
removeListener0(GenericFutureListener<? extends Future<? super V>> toRemove)

public Promise<V>
removeListeners(final GenericFutureListener<? extends Future<? super V>>... listeners)

Implements io.netty.util.concurrent.Promise.removeListeners, io.netty.util.concurrent.Future.removeListeners.

Removes the first occurrence for each of the listeners from this future.
private void
private static void
public Promise<V>
setFailure(Throwable cause)

Implements io.netty.util.concurrent.Promise.setFailure.

Marks this future as a failure and notifies all listeners.
private boolean
public Promise<V>
setSuccess(V result)

Implements io.netty.util.concurrent.Promise.setSuccess.

Marks this future as a success and notifies all listeners.
private boolean
setSuccess0(V result)

public boolean
setUncancellable()

Implements io.netty.util.concurrent.Promise.setUncancellable.

Make this future impossible to cancel.
private boolean
setValue0(Object objResult)

public Promise<V>
sync()

Implements io.netty.util.concurrent.Promise.sync, io.netty.util.concurrent.Future.sync.

Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
public Promise<V>
syncUninterruptibly()

Implements io.netty.util.concurrent.Promise.syncUninterruptibly, io.netty.util.concurrent.Future.syncUninterruptibly.

Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
protected StringBuilder
public boolean
tryFailure(Throwable cause)

Implements io.netty.util.concurrent.Promise.tryFailure.

Marks this future as a failure and notifies all listeners.
public boolean
trySuccess(V result)

Implements io.netty.util.concurrent.Promise.trySuccess.

Marks this future as a success and notifies all listeners.