|
| ACE_Timer_Wheel_T (FUNCTOR *upcall_functor=0, FreeList *freelist=0, TIME_POLICY const &time_policy=TIME_POLICY()) |
| Default constructor. More...
|
|
| ACE_Timer_Wheel_T (u_int spoke_count, u_int resolution, size_t prealloc=0, FUNCTOR *upcall_functor=0, FreeList *freelist=0, TIME_POLICY const &time_policy=TIME_POLICY()) |
| Constructor with opportunities to set the wheelsize and resolution. More...
|
|
virtual | ~ACE_Timer_Wheel_T (void) |
| Destructor. More...
|
|
virtual bool | is_empty (void) const |
| True if queue is empty, else false. More...
|
|
virtual const ACE_Time_Value & | earliest_time (void) const |
|
virtual int | reset_interval (long timer_id, const ACE_Time_Value &interval) |
|
virtual int | cancel (const TYPE &type, int dont_call_handle_close=1) |
|
virtual int | cancel (long timer_id, const void **act=0, int dont_call_handle_close=1) |
|
virtual int | close (void) |
|
virtual int | expire (void) |
|
int | expire (const ACE_Time_Value ¤t_time) |
|
virtual ACE_Timer_Queue_Iterator_T< TYPE > & | iter (void) |
| Returns a pointer to this <ACE_Timer_Queue_T>'s iterator. More...
|
|
virtual ACE_Timer_Node_T< TYPE > * | remove_first (void) |
| Removes the earliest node from the queue and returns it. More...
|
|
virtual void | dump (void) const |
| Dump the state of an object. More...
|
|
virtual ACE_Timer_Node_T< TYPE > * | get_first (void) |
| Reads the earliest node from the queue and returns it. More...
|
|
| ACE_Timer_Queue_T (FUNCTOR *upcall_functor=0, ACE_Free_List< ACE_Timer_Node_T< TYPE > > *freelist=0, TIME_POLICY const &time_policy=TIME_POLICY()) |
|
virtual | ~ACE_Timer_Queue_T (void) |
|
virtual long | schedule (const TYPE &type, const void *act, const ACE_Time_Value &future_time, const ACE_Time_Value &interval=ACE_Time_Value::zero) |
|
virtual int | dispatch_info (const ACE_Time_Value ¤t_time, ACE_Timer_Node_Dispatch_Info_T< TYPE > &info) |
|
virtual void | gettimeofday (ACE_Time_Value(*gettimeofday)(void)) |
|
ACE_Time_Value | gettimeofday_static () |
|
void | set_time_policy (TIME_POLICY const &time_policy) |
|
void | timer_skew (const ACE_Time_Value &skew) |
| Set the timer skew for the Timer_Queue. More...
|
|
const ACE_Time_Value & | timer_skew (void) const |
| Get the timer skew for the Timer_Queue. More...
|
|
ACE_LOCK & | mutex (void) |
| Synchronization variable used by the queue. More...
|
|
virtual void | return_node (ACE_Timer_Node_T< TYPE > *) |
|
void | preinvoke (ACE_Timer_Node_Dispatch_Info_T< TYPE > &info, const ACE_Time_Value &cur_time, const void *&upcall_act) |
| This method will call the preinvoke() on <functor>. More...
|
|
void | upcall (ACE_Timer_Node_Dispatch_Info_T< TYPE > &info, const ACE_Time_Value &cur_time) |
| This method will call the timeout() on <functor>. More...
|
|
void | postinvoke (ACE_Timer_Node_Dispatch_Info_T< TYPE > &info, const ACE_Time_Value &cur_time, const void *upcall_act) |
| This method will call the postinvoke() on <functor>. More...
|
|
virtual int | expire_single (ACE_Command_Base &pre_dispatch_command) |
|
virtual ACE_Time_Value | gettimeofday (void) |
|
virtual ACE_Time_Value * | calculate_timeout (ACE_Time_Value *max) |
|
virtual ACE_Time_Value * | calculate_timeout (ACE_Time_Value *max, ACE_Time_Value *the_timeout) |
|
virtual ACE_Time_Value | current_time () |
|
| ACE_Timer_Queue_Upcall_Base (FUNCTOR *upcall_functor=0) |
|
virtual | ~ACE_Timer_Queue_Upcall_Base (void) |
| Destructor. More...
|
|
FUNCTOR & | upcall_functor (void) |
| Accessor to the upcall functor. More...
|
|
virtual | ~ACE_Abstract_Timer_Queue (void)=0 |
| Destructor. More...
|
|
template<class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY = ACE_Default_Time_Policy>
class ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >
Provides a Timing Wheel version of ACE_Timer_Queue.
This implementation uses a hash table of ordered doubly- linked lists of absolute times. The enhancements over the ACE_Timer_List
include adding a free list and the ability to preallocate nodes. Timer Wheel is based on the timing wheel implementation used in Adam M. Costello and George Varghese's paper "Redesigning the BSD Callout and
Timer Facilities" (http://dworkin.wustl.edu/~varghese/PAPERS/newbsd.ps.Z)
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::ACE_Timer_Wheel_T |
( |
u_int |
spoke_count, |
|
|
u_int |
resolution, |
|
|
size_t |
prealloc = 0 , |
|
|
FUNCTOR * |
upcall_functor = 0 , |
|
|
FreeList * |
freelist = 0 , |
|
|
TIME_POLICY const & |
time_policy = TIME_POLICY() |
|
) |
| |
Constructor with opportunities to set the wheelsize and resolution.
Constructor that sets up the timing wheel and also may preallocate some nodes on the free list
- Parameters
-
spoke_count | The number of lists in the timer wheel |
resolution | The time resolution in milliseconds used by the hashing function |
prealloc | The number of entries to prealloc in the free_list |
upcall_functor | A pointer to a functor to use instead of the default |
freelist | A pointer to a freelist to use instead of the default |
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
int ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::cancel |
( |
const TYPE & |
type, |
|
|
int |
skip_close = 1 |
|
) |
| |
|
virtual |
Cancel all timer associated with type. If dont_call_handle_close is 0 then the <functor> will be invoked. Returns number of timers cancelled.
Goes through every list in the wheel and whenever we find one with the correct type value, we remove it and continue. At the end make sure we reset the earliest time value in case the earliest timers were removed.
- Parameters
-
type | The value to search for. |
skip_close | If this non-zero, the cancellation method of the functor will not be called for each cancelled timer. |
- Returns
- Number of timers cancelled
Implements ACE_Abstract_Timer_Queue< TYPE >.
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
int ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::cancel |
( |
long |
timer_id, |
|
|
const void ** |
act = 0 , |
|
|
int |
skip_close = 1 |
|
) |
| |
|
virtual |
Cancels the single timer that is specified by the timer_id. In this case the timer_id is actually a pointer to the node, so we cast it to the node. This can be dangerous if the timer_id is made up (or deleted twice) so we do a little sanity check. Finally we update the earliest time in case the earliest timer was removed.
- Parameters
-
timer_id | Timer Identifier |
act | Asychronous Completion Token (AKA magic cookie): If this is non-zero, stores the magic cookie of the cancelled timer here. |
skip_close | If this non-zero, the cancellation method of the functor will not be called. |
- Returns
- 1 for sucess and 0 if the timer_id wasn't found (or was found to be invalid)
Implements ACE_Abstract_Timer_Queue< TYPE >.
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
long ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::generate_timer_id |
( |
u_int |
spoke | ) |
|
|
private |
Generates a unique timer_id for the given spoke. It should be pretty fast until the point where the counter overflows. At that time you have to do exhaustive searches within the spoke to ensure that a particular timer id is not already in use. Some optimizations are in place so that this hopefully doesn't have to happen often.
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
bool ACE_Timer_Wheel_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >::is_empty |
( |
void |
| ) |
const |
|
virtual |
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
There are a few places where we have to figure out which timer will expire next. This method makes the assumption that spokes are always sorted, and that timers are always in the correct spoke determined from their expiration time. The last time is always passed in, even though you can often calculate it as get_first()->get_timer_value().
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
Changes the interval of a timer (and can make it periodic or non periodic by setting it to ACE_Time_Value::zero or not).
Find the timer node by using the id as a pointer. Then use set_interval() on the node to update the interval.
- Parameters
-
timer_id | The timer identifier |
interval | The new interval |
- Returns
- 0 if successful, -1 if no.
Implements ACE_Abstract_Timer_Queue< TYPE >.
template<class TYPE , class FUNCTOR , class ACE_LOCK , typename TIME_POLICY >
Schedules a timer.
Creates a ACE_Timer_Node_T based on the input parameters. Then inserts the node into the wheel using reschedule (). Then returns a timer_id.
- Parameters
-
type | The data of the timer node |
act | Asynchronous Completion Token (AKA magic cookie) |
future_time | The time the timer is scheduled for (absolute time) |
interval | If not ACE_Time_Value::zero, then this is a periodic timer and interval is the time period |
- Returns
- Unique identifier (can be used to cancel the timer). -1 on failure.
Implements ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY >.