Package com.android.testutils
Class VirtualTimeFuture<T>
- java.lang.Object
-
- com.android.testutils.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 theVirtualTimeSchedulerto 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 booleancancel(boolean mayInterruptIfRunning)intcompareTo(java.util.concurrent.Delayed o)Tget()Tget(long timeout, java.util.concurrent.TimeUnit unit)java.util.concurrent.Callable<T>getCallable()Gets the Callable this future is created for.longgetDelay(java.util.concurrent.TimeUnit unit)longgetId()Helper used by the scheduler's Comparator to distinguish/order futures scheduled for the same time.longgetOffset()Gets the Offset between invocations of the action behind this future, for repeated actions only.VirtualTimeSchedulergetOwningScheduler()Gets the VirtualTimeScheduler this future is associated with.VirtualTimeRepeatKindgetRepeatKind()Describes if this future is repeated and if so how.java.lang.RunnablegetRunnable()Gets the Runnable this future is created for.longgetTick()Gets the virtual time in nano seconds that this future is scheduled to execute at.booleanisCancelled()booleanisDone()
-
-
-
Method Detail
-
getDelay
public long getDelay(java.util.concurrent.TimeUnit unit)
- Specified by:
getDelayin interfacejava.util.concurrent.Delayed
-
compareTo
public int compareTo(java.util.concurrent.Delayed o)
- Specified by:
compareToin interfacejava.lang.Comparable<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancelin interfacejava.util.concurrent.Future<T>
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<T>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<T>
-
get
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.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:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.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.
-
-