mavis.util
Class LastExecutor.RunDelayed

java.lang.Object
  extended by mavis.util.LastExecutor.RunDelayed
All Implemented Interfaces:
java.lang.Comparable<java.util.concurrent.Delayed>, java.util.concurrent.Delayed
Enclosing class:
LastExecutor

private class LastExecutor.RunDelayed
extends java.lang.Object
implements java.util.concurrent.Delayed

Wraps a Runnable object and sets the delay after which it should be executed by a worker thread.


Field Summary
private  long expires
          The point in time when this RunDelayed will expire.
private  java.lang.Runnable runnable
          Contained Runnable object to be run after this RunDelayed has expired.
 
Constructor Summary
LastExecutor.RunDelayed(java.lang.Runnable runnable, int delayMillis)
          Creates a new RunDelayed item that contains runnable.
 
Method Summary
 int compareTo(java.util.concurrent.Delayed delayed)
          Compares this object with the specified object for order.
 long getDelay(java.util.concurrent.TimeUnit unit)
          Returns the remaining delay associated with this object, always in milliseconds.
 java.lang.Runnable getRunnable()
          Returns the contained Runnable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expires

private long expires
The point in time when this RunDelayed will expire.


runnable

private java.lang.Runnable runnable
Contained Runnable object to be run after this RunDelayed has expired.

Constructor Detail

LastExecutor.RunDelayed

public LastExecutor.RunDelayed(java.lang.Runnable runnable,
                               int delayMillis)
Creates a new RunDelayed item that contains runnable.

Parameters:
runnable - the Runnable to be contained
delayMillis - delay in milliseconds
Method Detail

getDelay

public long getDelay(java.util.concurrent.TimeUnit unit)
Returns the remaining delay associated with this object, always in milliseconds.

Specified by:
getDelay in interface java.util.concurrent.Delayed
Parameters:
unit - ignored; always assumed TimeUnit.MILLISECONDS
Returns:
the remaining delay; zero or negative values indicate that the delay has already elapsed

getRunnable

public java.lang.Runnable getRunnable()
Returns the contained Runnable.

Returns:
the Runnable given as constructor parameter

compareTo

public int compareTo(java.util.concurrent.Delayed delayed)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable<java.util.concurrent.Delayed>
Parameters:
delayed - the Delayed to be compared.
Returns:
a negative integer, zero, or a positive integer as this delay is less than, equal to, or greater than the specified delay.