class TimerList

XorpTimer creation and scheduling entity. More...

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

Public Methods


Detailed Description

A TimerList is a scheduling entity that provides a means to create XorpTimer objects and run them.

XorpTimer objects created via TimerList methods contain pointers to reference counted elements maintained in the TimerList. The elements on the list need to be referenced by XorpTimer objects or the underlying timer callbacks are never made. For instance:


TimerList timer_list;

XorpTimer t = timer_list.new_oneoff_after_ms(100, 
			callback(some_function, some_arg));

new_oneoff_after_ms(200, my_callback_b, my_parameter_a);

while ( ! timer_list.empty() ) {
	timer_list.run();
}

<code>my_callback_a</code> is called 100ms after the XorpTimer object is created.

<code>my_callback_b</code> is never called because no XorpTimer references the underlying element on the TimerList after <code>TimerList::new_oneoff_after_ms()</code> is called.

inline  TimerList (query_current_time q = system_gettimeofday)

TimerList

Parameters:
query_current_timespecifiable current time function. If no argument is supplied, gettimeofday is used.

inline  ~TimerList ()

~TimerList

void  run ()

run

Expire all pending XorpTimer objects associated with TimerList.

XorpTimer  new_oneoff_at (const timeval& when, const OneoffTimerCallback& ocb)

new_oneoff_at

Create a XorpTimer that will be scheduled once.

Parameters:
whenthe absolute time when the timer expires.
ocbcallback object that is invoked when timer expires.

Returns: the XorpTimer created.

XorpTimer  new_oneoff_after_ms (int ms, const OneoffTimerCallback& ocb)

new_oneoff_after_ms

Create a XorpTimer that will be scheduled once.

Parameters:
msthe relative time in milliseconds when the timer expires.
ocbcallback object that is invoked when timer expires.

Returns: the XorpTimer created.

XorpTimer  new_periodic (int ms, const PeriodicTimerCallback& pcb)

new_periodic

Create a XorpTimer that will invoke a callback periodically.

Parameters:
msthe period in milliseconds when the timer expires.
pcbuser callback object that is invoked when timer expires. If the callback returns false the periodic XorpTimer is unscheduled.

Returns: the XorpTimer created.

inline XorpTimer  new_oneoff_at (const timeval& when, OneoffTimerHook hook, void* thunk = 0)

new_oneoff_at

[Deprecated] Create a XorpTimer that will be scheduled once.

Parameters:
whenthe absolute time when the timer expires.
hookuser function that is invoked when timer expires.
thunkargument supplied to user function when timer expires.

Returns: the XorpTimer created.

inline XorpTimer  new_oneoff_after_ms (int ms, OneoffTimerHook hook, void* thunk = 0)

new_oneoff_after_ms

[Deprecated] Create a XorpTimer that will invoke a callback once.

Parameters:
msthe relative time in milliseconds when the timer expires.
hookuser function that is invoked when timer expires.
thunkargument supplied to user function when timer expires.

Returns: the XorpTimer created.

inline XorpTimer  new_periodic (int ms, PeriodicTimerHook hook, void* thunk = 0)

new_periodic

[Deprecated] Create a XorpTimer that will invoke a callback periodically.

Parameters:
msthe period in milliseconds when the timer expires.
hookuser function that is invoked when timer expires. If the hook returns false the periodic XorpTimer is unscheduled.
thunkargument supplied to user function when timer expires.

Returns: the XorpTimer created.

XorpTimer  set_flag_at (const timeval& when, bool* flag_ptr)

set_flag_at

Create a XorpTimer to set a flag.

Parameters:
whenthe absolute time when the timer expires.
flag_ptrpointer to a boolean variable that is set to false when this function is called and will be set to true when the XorpTimer expires.

Returns: the XorpTimer created.

XorpTimer  set_flag_after_ms (int ms, bool* flag_ptr)

set_flag_after_ms

Create a XorpTimer to set a flag.

Parameters:
msthe relative time in milliseconds when the timer expires.
flag_ptrpointer to a boolean variable that is set to false when this function is called and will be set to true when the XorpTimer expires.

Returns: the XorpTimer created.

inline XorpTimer  new_timer (const BasicTimerCallback& cb)

new_timer

Custom XorpTimer creation method. The XorpTimer object created needs to be explicitly scheduled with the available XorpTimer methods.

Parameters:
hookuser function to be invoked when XorpTimer expires.
thunkuser argument to be passed when user's function is invoked.

Returns: the XorpTimer created.

bool  empty ()

empty

[const]

Returns: true if there no XorpTimer objects currently scheduled on list.

size_t  size ()

size

[const]

Returns: the number of scheduled objects.

Reimplemented from Heap.

bool  get_next_delay (timeval& tv)

get_next_delay

[const]

Query the next XorpTimer Expiry time.

Parameters:
tvreference that is assigned expiry time of next timer. If there is no XorpTimer pending, this value is assigned the maximum timeval value.

Returns: true if there is a XorpTimer awaiting expiry, false otherwise.

inline void  current_time (timeval& now)

current_time

[const]

Read from clock used by TimerList object.

Parameters:
nowthe timeval structure to be assigned the current time.


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