All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class timer.TimerClient

java.lang.Object
   |
   +----timer.TimerClient

public class TimerClient
extends Object
A class to describe clients of the timer. All classes wishing to use the features of the timer will need to extend this class, and most will need to override the Timeout function as well. The purpose of this class is twofold:
  1. To describe the callback interface for timeouts. The method Timeout will be called (with the data object associated with the timeout) when timeouts fire. Clients using timeouts will therefore need to override this function.
  2. To implement synchronization correctly with respect to the timer. This class implements capitalized versions of the standard Java monitor functions. Clients of the timer will almost certainly want to use those functions in place of the builtin lowercase versions. In addition to allowing time to advance while a thread is blocked, they implement true FIFO queuing of Wait()ing threads, so that Notify wakes the oldest waiting thread.

    Also note: these monitor functions all operate on the global timer's monitor.


Constructor Index

 o TimerClient()
Set up the monitor state for the object

Method Index

 o Notify()
Wake up the first waiting thread on the queue, if any.
 o NotifyAll()
Wake up all waiting threads on the queue, if any.
 o NotifyThread(Thread)
A new monitor twist: Wake up a specific waiting thread on the queue, if present.
 o Timeout(Object)
the callback for timeouts.
 o Wait()
Block the currently executing thread indefiniately until Notify or NotifyAll is called.
 o Wait(long)
This function not yet implemented

Block the currently executing thread for at most us microseconds or until Notify or NotifyAll is called.

Constructors

 o TimerClient
 public TimerClient()
Set up the monitor state for the object

Methods

 o Timeout
 public void Timeout(Object info)
the callback for timeouts. When a timeout fires, this method on the client will be called. The default implementation does nothing.

Parameters:
info - the object which was passed to SetTimeout when this timeout was set
See Also:
SetTimeout
 o Wait
 public void Wait() throws IllegalMonitorStateException, IllegalTimerStateException
Block the currently executing thread indefiniately until Notify or NotifyAll is called. The current thread must hold the timer's monitor and be registered as blocking simulated time. While the thread is blocked both the monitor and simulated time will be released.

 o Wait
 public void Wait(long us) throws IllegalMonitorStateException, IllegalTimerStateException
This function not yet implemented

Block the currently executing thread for at most us microseconds or until Notify or NotifyAll is called. The current thread must hold the timer's monitor and be registered as blocking simulated time. While the thread is blocked both the monitor and simulated time will be released.

Parameters:
us - the maximum wait time in simulated microseconds
 o Notify
 public void Notify() throws IllegalMonitorStateException, IllegalTimerStateException
Wake up the first waiting thread on the queue, if any. Does not cause that thread to run immediately, just makes it runnable.

 o NotifyThread
 public void NotifyThread(Thread t) throws IllegalMonitorStateException, IllegalTimerStateException
A new monitor twist: Wake up a specific waiting thread on the queue, if present. Does not cause that thread to run immediately, just makes it runnable.

Parameters:
t - the thread to wake
 o NotifyAll
 public void NotifyAll() throws IllegalMonitorStateException, IllegalTimerStateException
Wake up all waiting threads on the queue, if any. Does not cause those thread sto run immediately, just makes them runnable.


All Packages  Class Hierarchy  This Package  Previous  Next  Index