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

Public Static 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 (const TimeVal& wait, const OneoffTimerCallback& ocb)

new_oneoff_after

Create a XorpTimer that will be scheduled once.

Parameters:
waitthe relative 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.

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 (const TimeVal& wait, bool *flag_ptr)

set_flag_after

Create a XorpTimer to set a flag.

Parameters:
waitthe relative 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::MAXIMUM(). The first function returns the absolute time at which the timer expires, where the second returns the difference between now and the expiry time.

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

bool  get_next_expire (TimeVal& tv)

get_next_expire

[const]

inline void  current_time (TimeVal& now)

current_time

[const]

Read from clock used by TimerList object.

Parameters:
nowthe return-by-reference value with the current time.

void  system_gettimeofday (TimeVal *tv)

system_gettimeofday

[static]

Default time querier.

Get the current time by using the default time querier. E.g., in non-simulation environment, this typically would be gettimeofday(2).

Parameters:
tva pointer to the TimeVal storage to store the current time.

void  set_observer (TimerListObserverBase& obs)

set_observer

Register an observer object with this class

Parameters:
obsan observer object derived from TimerListObserverBase

void  remove_observer ()

remove_observer

Unregister the current observer


Generated by: pavlin on possum.icir.org on Thu Nov 6 23:46:46 2003, using kdoc 2.0a54+XORP.