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>

public class ResourceFuture<V extends JPPFResourceWrapper> extends Object implements Future<V>
Future for handling class loading requests.
Author:
Laurent Cohen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected AtomicBoolean
    The cancellation status of the task represented by this future.
    protected AtomicBoolean
    The completion status of the task represented by this future.
    protected V
    The execution result.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initialize this future.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    cancel(boolean mayInterruptIfRunning)
    Attempts to cancel execution of this task.
    get()
    Waits if necessary for the computation to complete, and then retrieves its result.
    get(long timeout, TimeUnit unit)
    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.
    boolean
    Determine whether this task was cancelled before it completed normally.
    boolean
    Returns true if this task completed.
    void
    setDone(V response)
    Set this future as done and store the result.
    void
    Set the throwable that may have been raised during the class loading request execution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • done

      protected AtomicBoolean done
      The completion status of the task represented by this future.
    • cancelled

      protected AtomicBoolean cancelled
      The cancellation status of the task represented by this future.
    • response

      protected V extends JPPFResourceWrapper 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:
      cancel in interface Future<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:
      get in interface Future<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:
      get in interface Future<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:
      isCancelled in interface Future<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:
      isDone in interface Future<V extends JPPFResourceWrapper>
      Returns:
      true if the task completed.
      See Also:
    • setDone

      public void setDone(V response)
      Set this future as done and store the result.
      Parameters:
      response - the result to store.
    • getThrowable

      public Throwable getThrowable()
      Get the throwable that may have been raised during the class loading request execution.
      Returns:
      a Throwable object, or null if no throwable was raised.
    • setThrowable

      public void setThrowable(Throwable throwable)
      Set the throwable that may have been raised during the class loading request execution.
      Parameters:
      throwable - a Throwable object, or null if no throwable was raised.