net.sf.asyncobjects.util.timer
Class TimerUtils

java.lang.Object
  extended by net.sf.asyncobjects.util.timer.TimerUtils

public class TimerUtils
extends Object

Timer utils that provide simplified interface.

Author:
const

Constructor Summary
TimerUtils()
           
 
Method Summary
static
<T> Promise<T>
delayFor(ATimer timer, long delay, Promise<T> value)
          Delay returning value until spefied time
static
<T> Promise<T>
delayFor(ATimer timer, long delay, T value)
          Delay returning value until spefied time
static
<T> Promise<T>
delayUntil(ATimer timer, Date time, Promise<T> value)
          Delay returning value until spefied time
static
<T> Promise<T>
delayUntil(ATimer timer, Date time, T value)
          Delay returning value until spefied time
static Promise<Void> sleepFor(ATimer timer, long ms)
          Sleep the specified amount of milliseconds
static Promise<Void> sleepUntil(ATimer timer, Date time)
          Sleep the specified amount of milliseconds
static
<T> Promise<T>
timeout(ATimer timer, long delay, Throwable t)
          Smash result promise with the specified exception after specified time
static
<T> Promise<T>
timeoutAt(ATimer timer, Date time, Throwable t)
          Smash result promise with the specified exception after specified time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimerUtils

public TimerUtils()
Method Detail

sleepFor

public static Promise<Void> sleepFor(ATimer timer,
                                     long ms)
Sleep the specified amount of milliseconds

Parameters:
timer - a timer to use
ms - milliseconds to sleep
Returns:
when sleep finished

sleepUntil

public static Promise<Void> sleepUntil(ATimer timer,
                                       Date time)
Sleep the specified amount of milliseconds

Parameters:
timer - a timer to use
time - a time to to awaken
Returns:
when sleep finished

delayUntil

public static <T> Promise<T> delayUntil(ATimer timer,
                                        Date time,
                                        T value)
Delay returning value until spefied time

Type Parameters:
T - a type of value
Parameters:
timer - a timer to use
time - a time to to awaken
value - a value to return
Returns:
when sleep finished

delayUntil

public static <T> Promise<T> delayUntil(ATimer timer,
                                        Date time,
                                        Promise<T> value)
Delay returning value until spefied time

Type Parameters:
T - a type of value
Parameters:
timer - a timer to use
time - a time to to awaken
value - a value to return
Returns:
when sleep finished

delayFor

public static <T> Promise<T> delayFor(ATimer timer,
                                      long delay,
                                      T value)
Delay returning value until spefied time

Type Parameters:
T - a type of value
Parameters:
timer - a timer to use
delay - a delay to wait
value - a value to return
Returns:
when sleep finished

delayFor

public static <T> Promise<T> delayFor(ATimer timer,
                                      long delay,
                                      Promise<T> value)
Delay returning value until spefied time

Type Parameters:
T - a type of value
Parameters:
timer - a timer to use
delay - a delay to wait
value - a value to return
Returns:
when sleep finished

timeoutAt

public static <T> Promise<T> timeoutAt(ATimer timer,
                                       Date time,
                                       Throwable t)
Smash result promise with the specified exception after specified time

Type Parameters:
T - a promise type
Parameters:
timer - a timer to use
time - a time to to timeout
t - a problem to smash promise with
Returns:
when sleep finished

timeout

public static <T> Promise<T> timeout(ATimer timer,
                                     long delay,
                                     Throwable t)
Smash result promise with the specified exception after specified time

Type Parameters:
T - a promise type
Parameters:
timer - a timer to use
delay - a delay before timeout
t - a problem to smash promise with
Returns:
when sleep finished


Copyright © 2002-2007 Constantine Plotnikov. All Rights Reserved.