Top Description Fields Constructors Methods
org.apache.hc.core5.concurrent

public Class CompletedFuture<T>

extends Object
implements Future<T>, Cancellable
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.concurrent.Cancellable, java.util.concurrent.Future
Annotations
@Contract
threading:IMMUTABLE
Type Parameters
<T>
the future result type of an asynchronous operation.
Imports
java.util.concurrent.Future, .TimeUnit, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior

Immutable, completed future.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final T

Constructor Summary

AccessConstructor and Description
public
CompletedFuture(final T result)

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel(final 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 boolean
cancel()

Implements org.apache.hc.core5.concurrent.Cancellable.cancel.

Cancels the ongoing operation or process.
public T
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.
public T
get(final long
the maximum time to wait
timeout
,
final 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 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.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

resultback to summary
private final T result

Constructor Detail

CompletedFutureback to summary
public CompletedFuture(final T result)

Method Detail

cancelback to summary
public boolean cancel(final 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
cancelback to summary
public boolean cancel()

Implements org.apache.hc.core5.concurrent.Cancellable.cancel.

Doc from org.apache.hc.core5.concurrent.Cancellable.cancel.

Cancels the ongoing operation or process.

Returns:boolean

true if the operation or process has been cancelled as a result of this method call or false if it has already been cancelled or not started.

Annotations
@Override
getback to summary
public T get()

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:T

the computed result

Annotations
@Override
getback to summary
public T get(final long timeout, final TimeUnit unit)

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:T

the computed result

Annotations
@Override
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