|
|
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_time | specifiable 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:
when | the absolute time when the timer expires. |
ocb | callback 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:
wait | the relative time when the timer expires. |
ocb | callback 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:
ms | the relative time in milliseconds when the timer expires. |
ocb | callback 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:
ms | the period in milliseconds when the timer expires. |
pcb | user 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:
when | the absolute time when the timer expires. |
flag_ptr | pointer 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:
wait | the relative time when the timer expires. |
flag_ptr | pointer 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:
ms | the relative time in milliseconds when the timer expires. |
flag_ptr | pointer 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:
hook | user function to be invoked when XorpTimer expires. |
thunk | user 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:
tv | reference 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:
now | the 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:
tv | a 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:
obs | an observer object derived from TimerListObserverBase |
void remove_observer ()
| remove_observer |
Unregister the current observer
Generated by: pavlin on possum.icir.org on Thu Aug 28 12:51:57 2003, using kdoc 2.0a54+XORP. |