UM Java API  6.16.1
com.latencybusters.lbm.LBMTimer Class Reference

Public Member Functions

 LBMTimer (LBMContext lbmctx, long milliseconds) throws LBMException
 
 LBMTimer (LBMContext lbmctx, long milliseconds, LBMEventQueue lbmevq) throws LBMException
 
 LBMTimer (LBMContext lbmctx, long milliseconds, LBMTimerCallback cb, Object cbArg) throws LBMException
 
 LBMTimer (LBMContext lbmctx, long milliseconds, LBMTimerCallback cb, Object cbArg, LBMEventQueue lbmevq) throws LBMException
 
void addTimerCallback (LBMTimerCallback cb)
 
void addTimerCallback (LBMTimerCallback cb, Object cbArg)
 
void removeTimerCallback (LBMTimerCallback cb)
 
void removeTimerCallback (LBMTimerCallback cb, Object cbArg)
 
void cancel () throws LBMException
 
void cancel (boolean rescheduling) throws LBMException
 
void reschedule (long milliseconds) throws LBMException
 
LBMContext context ()
 

Detailed Description

LBM Timer class. This class can be subclassed in order to override the default onExpiration() method used to handle expiration of the timer or a constructor can be used to specify an LBMTimerCallback interface for handling the timer expiration callback.

Constructor & Destructor Documentation

com.latencybusters.lbm.LBMTimer.LBMTimer ( LBMContext  lbmctx,
long  milliseconds 
) throws LBMException

Creates a timer associated with a specific context that expires with a specified delay.

A zero duration timer is legal and causes the associated callback to be called as soon as possible on the context thread.

The timer object will not be collected by GC until the timer has expired or cancel() has been called, even if it goes out of scope.

Parameters
lbmctxLBMContext object with which to associate this timer (determines which LBM thread will execute the timer function).
millisecondsNumber of milliseconds until the timer expires
Exceptions
LBMExceptionif any timer scheduling error occurs.
com.latencybusters.lbm.LBMTimer.LBMTimer ( LBMContext  lbmctx,
long  milliseconds,
LBMEventQueue  lbmevq 
) throws LBMException

Creates a timer associated with a specific context and event queue that expires with a specified delay.

A zero duration timer is legal and causes the associated callback to be called as soon as possible on the context thread or to be enqueued as an event on the associated event queue. In this case, the event queue dispatching thread calls the associated callback after all currently pending events have been dispatched.

The timer object will not be collected by GC until the timer has expired or cancel() has been called, even if it goes out of scope.

Parameters
lbmctxLBMContext object with which to associate this timer
millisecondsNumber of milliseconds until the timer expires
lbmevqEvent queue with which to associate this timer (the timer events will be posted to this event queue)
Exceptions
LBMExceptionif any timer scheduling error occurs.
com.latencybusters.lbm.LBMTimer.LBMTimer ( LBMContext  lbmctx,
long  milliseconds,
LBMTimerCallback  cb,
Object  cbArg 
) throws LBMException

Creates a timer associated with a specific context that expires with a specified delay.

A zero duration timer is legal and causes the associated callback to be called as soon as possible on the context thread.

The timer object will not be collected by GC until the timer has expired or cancel() has been called, even if it goes out of scope.

Parameters
lbmctxLBMContext object with which to associate this timer (determines which LBM thread will execute the timer function).
millisecondsNumber of milliseconds until the timer expires
cbAn object implementing the LBMTimerCallback interface
cbArgCallback object passed as token to callback interface
Exceptions
LBMExceptionif any timer scheduling error occurs.

References com.latencybusters.lbm.LBMTimer.addTimerCallback().

com.latencybusters.lbm.LBMTimer.LBMTimer ( LBMContext  lbmctx,
long  milliseconds,
LBMTimerCallback  cb,
Object  cbArg,
LBMEventQueue  lbmevq 
) throws LBMException

Creates a timer associated with a specific context and event queue that expires with a specified delay.

A zero duration timer is legal and causes the associated callback to be called as soon as possible on the context thread or to be enqueued as an event on the associated event queue. In this case, the event queue dispatching thread calls the associated callback after all currently pending events have been dispatched.

The timer object will not be collected by GC until the timer has expired or cancel() has been called, even if it goes out of scope.

Parameters
lbmctxLBMContext object with which to associate this timer
millisecondsNumber of milliseconds until the timer expires
lbmevqEvent queue with which to associate this timer
cbAn object implementing the LBMTimerCallback interface
cbArgCallback object passed as token to callback interface (the timer events will be posted to this event queue)
Exceptions
LBMExceptionif any timer scheduling error occurs.

References com.latencybusters.lbm.LBMTimer.addTimerCallback().

Member Function Documentation

void com.latencybusters.lbm.LBMTimer.addTimerCallback ( LBMTimerCallback  cb)

Register a timer callback

Parameters
cbObject implementing the LBMTimerCallback interface
See also
LBMTimerCallback
removeTimerCallback

Referenced by com.latencybusters.lbm.LBMTimer.LBMTimer(), and com.latencybusters.lbm.LBMContext.scheduleTimer().

void com.latencybusters.lbm.LBMTimer.addTimerCallback ( LBMTimerCallback  cb,
Object  cbArg 
)

Register a timer callback (and callback token)

Parameters
cbObject implementing the LBMTimerCallback interface
cbArgCallback token object
See also
LBMTimerCallback
removeTimerCallback
void com.latencybusters.lbm.LBMTimer.cancel ( ) throws LBMException

Cancel timer

Exceptions
LBMExceptionif the timer was invalid or could not be cancelled.

Referenced by com.latencybusters.lbm.LBMTimer.reschedule().

void com.latencybusters.lbm.LBMTimer.cancel ( boolean  rescheduling) throws LBMException

Cancel timer

Parameters
reschedulingExternal users should always pass in false. Unexpected behavior may result if true is passed in.
Exceptions
LBMExceptionif the timer was invalid or could not be cancelled.
Deprecated:
This method is provided for backwards compatibility with LBM 3.3.7/UME 2.0.5; please use the cancel() method instead.
LBMContext com.latencybusters.lbm.LBMTimer.context ( )

Get the LBMContext object associated with this timer.

Returns
An LBMContext object.
void com.latencybusters.lbm.LBMTimer.removeTimerCallback ( LBMTimerCallback  cb)

Deregister a timer callback

Parameters
cbPreviously registered object implementing the LBMTimerCallback interface
See also
LBMTimerCallback
addTimerCallback
void com.latencybusters.lbm.LBMTimer.removeTimerCallback ( LBMTimerCallback  cb,
Object  cbArg 
)

Deregister a timer callback (and callback token)

Parameters
cbPreviously registered object implementing the LBMTimerCallback interface
cbArgCallback token for previously registered object
See also
LBMTimerCallback
addTimerCallback
void com.latencybusters.lbm.LBMTimer.reschedule ( long  milliseconds) throws LBMException

Reschedule this timer to expire in a specified number of milliseconds.

Parameters
millisecondsNumber of milliseconds until this timer should expire.
Exceptions
LBMExceptionif any timer scheduling error occurs.

References com.latencybusters.lbm.LBMTimer.cancel(), and com.latencybusters.lbm.LBMTimerCallback.onExpiration().

Referenced by com.latencybusters.lbm.LBMContext.scheduleTimer().


The documentation for this class was generated from the following file: