![]() |
![]() |
cnet's TimersA total of 10 software timer queues are supported to provide a call-back mechanism for user code. For example, when a data frame is transmitted a timer is typically created which will expire sometime after that frame's acknowledgement is expected. Timers are referenced via unique values termed timers of datatype CnetTimerID. When a timer expires, the event handler for the corresponding event (one of EV_TIMER0..EV_TIMER9) is invoked with the event and unique timer as parameters. Timers may be cancelled with CNET_stop_timer to prevent them expiring (for example, if the acknowledgement frame arrives before the timer expires). Timers are automatically cancelled as a result of their handler being invoked.
There are an unlimited number of timersIt is important to understand that an unlimited number of timers may be started on each queue - there are not just 10 timers. For example, the following section of code:
will produce output identical to that from:
In the first example, there are initially 10 timers running simultaneously. When each expires, the (same) handler for EV_TIMER3 will be called. In the second example, there is only ever 1 timer running at one time, and when it expires a new timer is started in the EV_TIMER3 event handler. |
cnet v3.3.4, written by Chris.McDonald@uwa.edu.au
Last modified: Tue Mar 1 7:43AM 2016