Class VirtualTimeFuture<T>

  • All Implemented Interfaces:
    java.lang.Comparable<java.util.concurrent.Delayed>, java.util.concurrent.Delayed, java.util.concurrent.Future<T>, java.util.concurrent.ScheduledFuture<T>

    public class VirtualTimeFuture<T>
    extends java.lang.Object
    implements java.util.concurrent.ScheduledFuture<T>
    Future used by the VirtualTimeScheduler to track the actions scheduled on it. Allows for introspection of the scheduled action through various helper methods.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cancel​(boolean mayInterruptIfRunning)  
      int compareTo​(java.util.concurrent.Delayed o)  
      T get()  
      T get​(long timeout, java.util.concurrent.TimeUnit unit)  
      java.util.concurrent.Callable<T> getCallable()
      Gets the Callable this future is created for.
      long getDelay​(java.util.concurrent.TimeUnit unit)  
      long getId()
      Helper used by the scheduler's Comparator to distinguish/order futures scheduled for the same time.
      long getOffset()
      Gets the Offset between invocations of the action behind this future, for repeated actions only.
      VirtualTimeScheduler getOwningScheduler()
      Gets the VirtualTimeScheduler this future is associated with.
      VirtualTimeRepeatKind getRepeatKind()
      Describes if this future is repeated and if so how.
      java.lang.Runnable getRunnable()
      Gets the Runnable this future is created for.
      long getTick()
      Gets the virtual time in nano seconds that this future is scheduled to execute at.
      boolean isCancelled()  
      boolean isDone()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getDelay

        public long getDelay​(java.util.concurrent.TimeUnit unit)
        Specified by:
        getDelay in interface java.util.concurrent.Delayed
      • compareTo

        public int compareTo​(java.util.concurrent.Delayed o)
        Specified by:
        compareTo in interface java.lang.Comparable<T>
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<T>
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface java.util.concurrent.Future<T>
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface java.util.concurrent.Future<T>
      • get

        public T get()
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • get

        public T get​(long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException,
                     java.util.concurrent.TimeoutException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • getTick

        public long getTick()
        Gets the virtual time in nano seconds that this future is scheduled to execute at.
      • getRunnable

        public java.lang.Runnable getRunnable()
        Gets the Runnable this future is created for.
      • getCallable

        public java.util.concurrent.Callable<T> getCallable()
        Gets the Callable this future is created for.
      • getOwningScheduler

        public VirtualTimeScheduler getOwningScheduler()
        Gets the VirtualTimeScheduler this future is associated with.
      • getOffset

        public long getOffset()
        Gets the Offset between invocations of the action behind this future, for repeated actions only.
      • getRepeatKind

        public VirtualTimeRepeatKind getRepeatKind()
        Describes if this future is repeated and if so how.
      • getId

        public long getId()
        Helper used by the scheduler's Comparator to distinguish/order futures scheduled for the same time.