基础组件
ACE_Abstract_Timer_Queue
模板类,定时器队列的抽象类
ACE_Abstract_Timer_Queue<TYPE>
+bool is_empty(void)
+const ACE_Time_Value &earliest_time(void)
+long schedule(const TYPE &type, const void *act,const ACE_Time_Value &future_time, const ACE_Time_Value &interval = ACE_Time_Value::zero)
+int expire(const ACE_Time_Value ¤t_time)
+int expire(void)
+int expire_single(ACE_Command_Base & pre_dispatch_command)
+int reset_interval(long timer_id, const ACE_Time_Value &interval)
+int cancel(const TYPE &type, int dont_call_handle_close = 1)
+int cancel(long timer_id, const void **act = 0, int dont_call_handle_close = 1)
+int close(void)
+ACE_Time_Value gettimeofday(void)
+void gettimeofday(ACE_Time_Value (*gettimeofday)
+ACE_Time_Value *calculate_timeout(ACE_Time_Value *max)
+ACE_Time_Value *calculate_timeout(ACE_Time_Value *max, ACE_Time_Value *the_timeout)
+ACE_Time_Value current_time()
+ITERATOR & iter(void)
+ACE_Timer_Node_T *remove_first(void)
+ACE_Timer_Node_T *get_first(void)
+void dump(void)
方法都为纯虚函数
ACE_Timer_Queue_Upcall_Base
模板类,继承ACE_Abstract_Timer_Queue,提供回调功能
ACE_Timer_Queue_Upcall_Base<TYPE, FUNCTOR>
#FUNCTOR *upcall_functor_
#bool const delete_upcall_functor_
+FUNCTOR & upcall_functor(void)
ACE_Abstract_Timer_Queue<TYPE>
ACE_Timer_Queue_T
模板类,继承ACE_Timer_Queue_Upcall_Base,是其它定时器队列的实现基类
ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
#ACE_LOCK mutex_
#ACE_Free_List > *free_list_
#TIME_POLICY time_policy_
#bool const delete_free_list_
- ACE_Time_Value timeout_
- ACE_Time_Value timer_skew_
#long schedule_i(const TYPE &type, const void *act,const ACE_Time_Value &future_time, const ACE_Time_Value &interval)
#void reschedule(ACE_Timer_Node_T *)
ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>
ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
schedule_i 和reschedule纯虚函数,由具体的定时器队列子类实现 schedule:会调用schedule_i,以及调用this->upcall_functor ().registration (*this,type,act);
包含的子类有
ACE_Timer_Heap_T:堆实现的定时器队列 ACE_Timer_Hash_T:哈希表实现的定时器队列 ACE_Timer_List_T:链表实现的定时器队列 ACE_Timer_Wheel_T:时间轮实现的定时器队列
使用
在Reactor的实现类使用,其作为实现类的成员
ACE_Timer_Queue * timer_queue_;
ACE_Timer_Queue是ACE_Abstract_Timer_Queue<ACE_Event_Handler*>
的别名
typedef ACE_Abstract_Timer_Queue< ACE_Event_Handler* > ACE_Timer_Queue;
Reactor的实现类有
ACE_TP_Reactor ACE_Dev_Poll_Reactor ACE_Select_Reactor ACE_Msg_WFMO_Reactor ACE_WFMO_Reactor 在其对应的open方法中创建,默认是使用ACE_Timer_Heap
if ( result != - 1 && this -> timer_queue_ == 0 )
{
ACE_NEW_RETURN ( this -> timer_queue_,
ACE_Timer_Heap,
- 1 ) ;
this -> delete_timer_queue_ = true ;
}