next up previous contents index
Next: 11.3 Commands at a Up: 11. Timers Previous: 11.1.2 Example: Tcp retransmission   Contents   Index


11.2 OTcl Timer class

A simple timer class is defined in ~ns/tcl/mcast/timer.tcl. Subclasses of Timer can be defined as needed. Unlike the C++ timer API, where a []sched aborts if the timer is already set, []sched and []resched are the same; i.e., no state is kept for the OTcl timers. The following methods are defined in the Timer base class:

    $self sched $delay   # causes "$self timeout" to be called $delay seconds in the future;
    $self resched $delay # same as "$self sched $delay" ;
    $self cancel         # cancels any pending scheduled callback;
    $self destroy        # same as "$self cancel";
    $self expire         # calls "$self timeout" immediately;



2008-12-02