au.com.terabit.jproactor
Class OpTimer

java.lang.Object
  extended by au.com.terabit.jproactor.OpTimer

public final class OpTimer
extends java.lang.Object

This class provides implementation of the timer operations.

Version:
$Revision$ $Date$
Author:
Yevgeny Libman

Nested Class Summary
static class OpTimer.State
          Timer state values
 
Field Summary
 long m_expiryTime
          Timer expiration time: number of milliseconds since 1 Jan 1970 00:00:00 GMT
 
Constructor Summary
OpTimer(long delay, AsynchTimerHandler handler)
           
 
Method Summary
 java.lang.Object attach(java.lang.Object value)
          Attaches an object to this operation.
 java.lang.Object attachment()
          Returns currently attached object.
 void cancel()
          Cancels this timer
 boolean isCancelled()
           
 void onComplete()
          Called when timer has expired - notifies protocol instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_expiryTime

public final long m_expiryTime
Timer expiration time: number of milliseconds since 1 Jan 1970 00:00:00 GMT

Constructor Detail

OpTimer

public OpTimer(long delay,
               AsynchTimerHandler handler)
Parameters:
handler - the timer notification receiver
delay - time delay from now when to expire the timer, milliseconds
Method Detail

onComplete

public void onComplete()
Called when timer has expired - notifies protocol instance.

See Also:
IOOperation.onComplete()

cancel

public void cancel()
Cancels this timer


isCancelled

public boolean isCancelled()

attach

public final java.lang.Object attach(java.lang.Object value)
Attaches an object to this operation.

Attachments can be useful when executig onComplete() operation and be retrieved using attachment() operation.

Parameters:
value - object to be attached, can be a null value
Returns:
The previously-attached object, if any, otherwise null

attachment

public final java.lang.Object attachment()
Returns currently attached object.

Returns:
attachement