class TimerList

XorpTimer creation and scheduling entity. More...

 
LOGO
 Annotated List  Files  Globals  Hierarchy  Index  Top

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.

 TimerList (ClockBase* clock)

TimerList

Parameters:

clockclock object to use to query time.
 ~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 (const TimeVal& wait, const PeriodicTimerCallback& pcb)

new_periodic

Create a XorpTimer that will invoke a callback periodically.

Parameters:

waitthe period 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  new_periodic_ms (int ms, const PeriodicTimerCallback& pcb)

new_periodic_ms

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, bool to_value = true)

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 to_value when the XorpTimer expires.

Returns: the XorpTimer created.

XorpTimer  set_flag_after (const TimeVal& wait, bool *flag_ptr, bool to_value = true)

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 to_value when the XorpTimer expires.

Returns: the XorpTimer created.

XorpTimer  set_flag_after_ms (int ms, bool* flag_ptr, bool to_value = true)

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 to_value 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.

void  current_time (TimeVal& now)

current_time

[const]

Read the latest known value from the clock used by TimerList object.

Parameters:

nowthe return-by-reference value with the current time.
void  advance_time ()

advance_time

Advance time. This method fetches the time from clock object associated with the TimerList and sets the TimerList current time to this value.

void  system_gettimeofday (TimeVal* tv)

system_gettimeofday

[static]

Default time querier.

Get the current time. This method is analogous to calling the underlying operating system's 'get current system time' function and is implemented as a call to advance_time() followed by a call to current_time().

Parameters:

tva pointer to the TimeVal storage to store the current time.
void  system_sleep (const TimeVal& tv)

system_sleep

[static]

Suspend process execution for a defined interval.

This methid is analogous to calling sleep(3) or usleep(3), and is implemented as a call to sleep(3) and/or usleep(3) followed by a call to advance_time().

Parameters:

tvthe period of time to suspend execution.
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

TimerList*  instance ()

instance

[static]

Get pointer to sole TimerList instance.

Returns: pointer if TimerList has been constructed, NULL otherwise.


Generated by: pavlin on possum.icir.org on Wed Aug 2 15:35:43 2006, using kdoc $.