Package org.jppf.classloader
Class ResourceFuture<V extends JPPFResourceWrapper>
java.lang.Object
org.jppf.classloader.ResourceFuture<V>
- Type Parameters:
V- the type of result returned by this future.
- All Implemented Interfaces:
Future<V>
Future for handling class loading requests.
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicBooleanThe cancellation status of the task represented by this future.protected AtomicBooleanThe completion status of the task represented by this future.protected VThe execution result. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) Attempts to cancel execution of this task.get()Waits if necessary for the computation to complete, and then retrieves its result.Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.Get the throwable that may have been raised during the class loading request execution.booleanDetermine whether this task was cancelled before it completed normally.booleanisDone()Returns true if this task completed.voidSet this future as done and store the result.voidsetThrowable(Throwable throwable) Set the throwable that may have been raised during the class loading request execution.
-
Field Details
-
done
The completion status of the task represented by this future. -
cancelled
The cancellation status of the task represented by this future. -
response
The execution result.
-
-
Constructor Details
-
ResourceFuture
public ResourceFuture()Initialize this future.
-
-
Method Details
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) Attempts to cancel execution of this task. This attempt will fail if the task has already completed, already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run.- Specified by:
cancelin interfaceFuture<V extends JPPFResourceWrapper>- Parameters:
mayInterruptIfRunning- true if the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete.- Returns:
- this method always returns false.
- See Also:
-
get
Waits if necessary for the computation to complete, and then retrieves its result.- Specified by:
getin interfaceFuture<V extends JPPFResourceWrapper>- Returns:
- the computed result.
- Throws:
InterruptedException- if the current thread was interrupted while waiting.ExecutionException- if the computation threw an exception.- See Also:
-
get
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.- Specified by:
getin interfaceFuture<V extends JPPFResourceWrapper>- Parameters:
timeout- the maximum time to wait.unit- the time unit of the timeout argument.- Returns:
- the computed result.
- Throws:
InterruptedException- if the current thread was interrupted while waiting.ExecutionException- if the computation threw an exception.TimeoutException- if the wait timed out.- See Also:
-
isCancelled
public boolean isCancelled()Determine whether this task was cancelled before it completed normally.- Specified by:
isCancelledin interfaceFuture<V extends JPPFResourceWrapper>- Returns:
- true if this task was cancelled before it completed normally.
- See Also:
-
isDone
public boolean 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.- Specified by:
isDonein interfaceFuture<V extends JPPFResourceWrapper>- Returns:
- true if the task completed.
- See Also:
-
setDone
Set this future as done and store the result.- Parameters:
response- the result to store.
-
getThrowable
Get the throwable that may have been raised during the class loading request execution.- Returns:
- a
Throwableobject, ornullif no throwable was raised.
-
setThrowable
Set the throwable that may have been raised during the class loading request execution.- Parameters:
throwable- aThrowableobject, ornullif no throwable was raised.
-