com.latencybusters.lbm
Class LBMTimer

java.lang.Object
  extended by com.latencybusters.lbm.LBMTimer

public class LBMTimer
extends java.lang.Object

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 Summary
LBMTimer(LBMContext lbmctx, long milliseconds)
          Creates a timer associated with a specific context that expires with a specified delay.
LBMTimer(LBMContext lbmctx, long milliseconds, LBMEventQueue lbmevq)
          Creates a timer associated with a specific context and event queue that expires with a specified delay.
LBMTimer(LBMContext lbmctx, long milliseconds, LBMTimerCallback cb, java.lang.Object cbArg)
          Creates a timer associated with a specific context that expires with a specified delay.
LBMTimer(LBMContext lbmctx, long milliseconds, LBMTimerCallback cb, java.lang.Object cbArg, LBMEventQueue lbmevq)
          Creates a timer associated with a specific context and event queue that expires with a specified delay.
 
Method Summary
 void addTimerCallback(LBMTimerCallback cb)
          Register a timer callback
 void addTimerCallback(LBMTimerCallback cb, java.lang.Object cbArg)
          Register a timer callback (and callback token)
 void cancel()
          Cancel timer
 void cancel(boolean rescheduling)
          Deprecated. This method is provided for backwards compatibility with LBM 3.3.7/UME 2.0.5; please use the cancel() method instead.
 LBMContext context()
          Get the LBMContext object associated with this timer.
 void removeTimerCallback(LBMTimerCallback cb)
          Deregister a timer callback
 void removeTimerCallback(LBMTimerCallback cb, java.lang.Object cbArg)
          Deregister a timer callback (and callback token)
 void reschedule(long milliseconds)
          Reschedule this timer to expire in a specified number of milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LBMTimer

public 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:
lbmctx - LBMContext object with which to associate this timer (determines which LBM thread will execute the timer function).
milliseconds - Number of milliseconds until the timer expires
Throws:
LBMException - if any timer scheduling error occurs.

LBMTimer

public 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:
lbmctx - LBMContext object with which to associate this timer
milliseconds - Number of milliseconds until the timer expires
lbmevq - Event queue with which to associate this timer (the timer events will be posted to this event queue)
Throws:
LBMException - if any timer scheduling error occurs.

LBMTimer

public LBMTimer(LBMContext lbmctx,
                long milliseconds,
                LBMTimerCallback cb,
                java.lang.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:
lbmctx - LBMContext object with which to associate this timer (determines which LBM thread will execute the timer function).
milliseconds - Number of milliseconds until the timer expires
cb - An object implementing the LBMTimerCallback interface
cbArg - Callback object passed as token to callback interface
Throws:
LBMException - if any timer scheduling error occurs.

LBMTimer

public LBMTimer(LBMContext lbmctx,
                long milliseconds,
                LBMTimerCallback cb,
                java.lang.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:
lbmctx - LBMContext object with which to associate this timer
milliseconds - Number of milliseconds until the timer expires
lbmevq - Event queue with which to associate this timer
cb - An object implementing the LBMTimerCallback interface
cbArg - Callback object passed as token to callback interface (the timer events will be posted to this event queue)
Throws:
LBMException - if any timer scheduling error occurs.
Method Detail

addTimerCallback

public void addTimerCallback(LBMTimerCallback cb)
Register a timer callback

Parameters:
cb - Object implementing the LBMTimerCallback interface
See Also:
LBMTimerCallback, removeTimerCallback(com.latencybusters.lbm.LBMTimerCallback)

addTimerCallback

public void addTimerCallback(LBMTimerCallback cb,
                             java.lang.Object cbArg)
Register a timer callback (and callback token)

Parameters:
cb - Object implementing the LBMTimerCallback interface
cbArg - Callback token object
See Also:
LBMTimerCallback, removeTimerCallback(com.latencybusters.lbm.LBMTimerCallback)

removeTimerCallback

public void removeTimerCallback(LBMTimerCallback cb)
Deregister a timer callback

Parameters:
cb - Previously registered object implementing the LBMTimerCallback interface
See Also:
LBMTimerCallback, addTimerCallback(com.latencybusters.lbm.LBMTimerCallback)

removeTimerCallback

public void removeTimerCallback(LBMTimerCallback cb,
                                java.lang.Object cbArg)
Deregister a timer callback (and callback token)

Parameters:
cb - Previously registered object implementing the LBMTimerCallback interface
cbArg - Callback token for previously registered object
See Also:
LBMTimerCallback, addTimerCallback(com.latencybusters.lbm.LBMTimerCallback)

cancel

public void cancel()
            throws LBMException
Cancel timer

Throws:
LBMException - if the timer was invalid or could not be cancelled.

cancel

public void cancel(boolean rescheduling)
            throws LBMException
Deprecated. This method is provided for backwards compatibility with LBM 3.3.7/UME 2.0.5; please use the cancel() method instead.

Cancel timer

Parameters:
rescheduling - External users should always pass in false. Unexpected behavior may result if true is passed in.
Throws:
LBMException - if the timer was invalid or could not be cancelled.

reschedule

public void reschedule(long milliseconds)
                throws LBMException
Reschedule this timer to expire in a specified number of milliseconds.

Parameters:
milliseconds - Number of milliseconds until this timer should expire.
Throws:
LBMException - if any timer scheduling error occurs.

context

public LBMContext context()
Get the LBMContext object associated with this timer.

Returns:
An LBMContext object.


All of the documentation and software included in this and any other Informatica Inc "Ultra Messaging" Release is Copyright (C) 2004-2014, Informatica Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted only as covered by the terms of a valid software license agreement with 29West Inc. Copyright © 2004-2014, Informatica, Inc. All Rights Reserved.