Top Fields Constructors Methods
org.eclipse.jetty.util

public Class FuturePromise<C>

extends Object
implements Future<C>, Promise<C>
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.Promise, java.util.concurrent.Future
Imports
java.io.IOException, java.util.concurrent.CancellationException, .CountDownLatch, .ExecutionException, .Future, .TimeUnit, .TimeoutException, java.util.concurrent.atomic.AtomicBoolean

Field Summary

Modifier and TypeField and Description
private Throwable
private final AtomicBoolean
private final CountDownLatch
private C
private static Throwable

Constructor Summary

AccessConstructor and Description
public
public
FuturePromise(C result)

public
FuturePromise(C ctx, Throwable failed)

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel(boolean
true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete
mayInterruptIfRunning
)

Implements java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.
public void
failed(Throwable
the reason for the operation failure
cause
)

Overrides default org.eclipse.jetty.util.Promise.failed.

Callback invoked when the operation fails.

public C
get()

Implements java.util.concurrent.Future.get.

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

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 C

Returns:

the computed result
getOrThrow
()

Return the result if completed successfully or in the case of failure, throw the Exception/Error, or an ExecutionException wrapping the cause if it is neither an Exception or Error.

public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

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

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.
public static void
public void
succeeded(C
the context
result
)

Overrides default org.eclipse.jetty.util.Promise.succeeded.

Callback invoked when the operation completes.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_causeback to summary
private Throwable _cause
_doneback to summary
private final AtomicBoolean _done
_latchback to summary
private final CountDownLatch _latch
_resultback to summary
private C _result
COMPLETEDback to summary
private static Throwable COMPLETED

Constructor Detail

FuturePromiseback to summary
public FuturePromise()
FuturePromiseback to summary
public FuturePromise(C result)
FuturePromiseback to summary
public FuturePromise(C ctx, Throwable failed)

Method Detail

cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Doc from java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task. This method has no effect if the task is already completed or cancelled, or could not be cancelled for some other reason. Otherwise, if this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.

The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled.

Parameters
mayInterruptIfRunning:boolean

true if the thread executing this task should be interrupted (if the thread is known to the implementation); otherwise, in-progress tasks are allowed to complete

Returns:boolean

false if the task could not be cancelled, typically because it has already completed; true otherwise. If two or more threads cause a task to be cancelled, then at least one of them returns true. Implementations may provide stronger guarantees.

Annotations
@Override
failedback to summary
public void failed(Throwable cause)

Overrides default org.eclipse.jetty.util.Promise.failed.

Doc from org.eclipse.jetty.util.Promise.failed.

Callback invoked when the operation fails.

Parameters
cause:Throwable

the reason for the operation failure

Annotations
@Override
getback to summary
public C get() throws InterruptedException, ExecutionException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Returns:C

the computed result

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
getback to summary
public C get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Implements java.util.concurrent.Future.get.

Doc from 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.

Parameters
timeout:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:C

the computed result

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
TimeoutException:
if the wait timed out
getOrThrowback to summary
public C getOrThrow() throws Exception

Return the result if completed successfully or in the case of failure, throw the Exception/Error, or an ExecutionException wrapping the cause if it is neither an Exception or Error.

Returns:C

the computed result

Exceptions
Exception:
if the cause is an Exception or Error, otherwise an ExecutionException wrapping the cause
isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Returns:boolean

true if this task was cancelled before it completed

Annotations
@Override
isDoneback to summary
public boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Returns:boolean

true if this task completed

Annotations
@Override
rethrowback to summary
public static void rethrow(ExecutionException e) throws IOException
succeededback to summary
public void succeeded(C result)

Overrides default org.eclipse.jetty.util.Promise.succeeded.

Doc from org.eclipse.jetty.util.Promise.succeeded.

Callback invoked when the operation completes.

Parameters
result:C

the context

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override