class Timer

The timer class. More...

Definition#include <timer.hh>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

Note that this timer is used only by the multicast code.

 Timer ()

Timer

Default constructor

 ~Timer ()

~Timer

Destructor

bool  is_set ()

is_set

[const]

Test if the timer is set.

Returns: true if the timer is set (i.e., running), otherwise false.

void  start (uint32_t delay_sec, uint32_t delay_usec, cfunc_t func, void *data_pointer)

start

Start the timer

This method will start a one-time timer. If the timer should be periodic, it should be restarted by the timeout function.

Parameters:
delay_secthe number of seconds to the timer expiration.
delay_usecthe number of microseconds (in addition to the number of seconds delay_sec) to the timer expiration.
functhe timeout function to call when the timer expires.
data_pointerthe data to supply to the timeout function func when the timer expires.

void  start_random (uint32_t delay_sec, uint32_t delay_usec, cfunc_t func, void *data_pointer, double random_factor)

start_random

Start the timer with a randomized timeout expiration period.

This method will start a one-time timer. If the timer should be (randomly) periodic, it should be restarted by the timeout function. The scheduled randomized time is uniformly randomly selected in the interval delay +- delay*random_factor. For example, if random_factor is 0.5, the random interval is (0.5*delay, 1.5*delay)

Parameters:
delay_secthe number of seconds (used in the randomized computation) to the timer expiration.
delay_usecthe number of microseconds (used in the randomized computation in addition to the number of seconds delay_sec) to the timer expiration.
functhe timeout function to call when the timer expires.
data_pointerthe data to supply to the timeout function func when the timer expires.
random_factorthe randomization factor.

void  start_semaphore (uint32_t delay_sec, uint32_t delay_usec)

start_semaphore

Start a semaphore

A semaphore is a timer without a timeout function. It is used only to indicate whether some interval of time has expired or not.

Parameters:
delay_secthe number of seconds to the semaphore expiration.
delay_usecthe number of microseconds (in addition to the number of seconds delay_sec) to the semaphore expiration.

void  cancel ()

cancel

Cancel the timer

uint32_t  left_sec ()

left_sec

[const]

Get the number of seconds until the timer expires.

Returns: the number of seconds until the timer expires. Note that if the timer is not set, the return value is 0 (zero seconds).

uint32_t  left_timeval (struct timeval *timeval_diff)

left_timeval

[const]

Get the remaining expiration time

Compute the expiration time for the timer.

Parameters:
timeval_diffthe timeval structure to store the result. Note that if the timer is not set, the timeval structure will be reset to (0, 0); i.e., zero seconds and zero microseconds.

Returns: the number of seconds until the timer expire. Note that if the timer is not set, the return value is 0 (zero seconds).


Generated by: pavlin on possum.icir.org on Wed Dec 11 16:50:45 2002, using kdoc 2.0a54+XORP.