diff options
-rw-r--r-- | ace/Proactor.cpp | 36 | ||||
-rw-r--r-- | ace/Proactor.h | 54 | ||||
-rw-r--r-- | ace/Synch_T.h | 4 | ||||
-rw-r--r-- | ace/Timer_Heap.h | 8 | ||||
-rw-r--r-- | ace/Timer_Heap_T.cpp | 172 | ||||
-rw-r--r-- | ace/Timer_Heap_T.h | 52 | ||||
-rw-r--r-- | ace/Timer_List.h | 8 | ||||
-rw-r--r-- | ace/Timer_List_T.cpp | 143 | ||||
-rw-r--r-- | ace/Timer_List_T.h | 36 | ||||
-rw-r--r-- | ace/Timer_Queue.cpp | 36 | ||||
-rw-r--r-- | ace/Timer_Queue.h | 26 | ||||
-rw-r--r-- | ace/Timer_Queue_T.cpp | 112 | ||||
-rw-r--r-- | ace/Timer_Queue_T.h | 69 | ||||
-rw-r--r-- | ace/Timer_Queue_T.i | 47 | ||||
-rw-r--r-- | ace/Timer_Wheel.h | 8 | ||||
-rw-r--r-- | ace/Timer_Wheel_T.cpp | 344 | ||||
-rw-r--r-- | ace/Timer_Wheel_T.h | 44 |
17 files changed, 611 insertions, 588 deletions
diff --git a/ace/Proactor.cpp b/ace/Proactor.cpp index 04eaf1d6bdc..f86a4a45b1d 100644 --- a/ace/Proactor.cpp +++ b/ace/Proactor.cpp @@ -109,10 +109,10 @@ ACE_Proactor_Handle_Timeout_Upcall::ACE_Proactor_Handle_Timeout_Upcall (void) } int -ACE_Proactor_Handle_Timeout_Upcall::operator () (TIMER_QUEUE &timer_queue, - ACE_Handler *handler, - const void *act, - const ACE_Time_Value &time) +ACE_Proactor_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &timer_queue, + ACE_Handler *handler, + const void *act, + const ACE_Time_Value &time) { ACE_UNUSED_ARG (timer_queue); @@ -151,8 +151,8 @@ ACE_Proactor_Handle_Timeout_Upcall::operator () (TIMER_QUEUE &timer_queue, int -ACE_Proactor_Handle_Timeout_Upcall::operator () (TIMER_QUEUE &timer_queue, - ACE_Handler *handler) +ACE_Proactor_Handle_Timeout_Upcall::cancellation (TIMER_QUEUE &timer_queue, + ACE_Handler *handler) { ACE_UNUSED_ARG (timer_queue); ACE_UNUSED_ARG (handler); @@ -539,23 +539,23 @@ ACE_Proactor::Asynch_Timer::complete (u_long bytes_transferred, #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> *>; -template class ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> *>; -template class ACE_Node<ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> *>; +template class ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> *>; +template class ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> *>; +template class ACE_Node<ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> *>; -template class ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; +template class ACE_Timer_Node_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Timer_Queue_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; -template class ACE_Timer_Queue_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; +template class ACE_Timer_Queue_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Queue_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Timer_List_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; -template class ACE_Timer_List_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; +template class ACE_Timer_List_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_List_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Timer_Heap_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; -template class ACE_Timer_Heap_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; +template class ACE_Timer_Heap_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Heap_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Timer_Wheel_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; -template class ACE_Timer_Wheel_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall>; +template class ACE_Timer_Wheel_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Wheel_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/ace/Proactor.h b/ace/Proactor.h index 4d899b79b38..45b1b27c472 100644 --- a/ace/Proactor.h +++ b/ace/Proactor.h @@ -49,19 +49,21 @@ class ACE_Export ACE_Proactor_Handle_Timeout_Upcall // Access needed to: proactor () public: - typedef ACE_Timer_Queue_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> TIMER_QUEUE; + typedef ACE_Timer_Queue_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> TIMER_QUEUE; ACE_Proactor_Handle_Timeout_Upcall (void); // Constructor - int operator () (TIMER_QUEUE &timer_queue, - ACE_Handler *handler, - const void *arg, - const ACE_Time_Value &cur_time); + int timeout (TIMER_QUEUE &timer_queue, + ACE_Handler *handler, + const void *arg, + const ACE_Time_Value &cur_time); // This method is called when the timer expires - int operator () (TIMER_QUEUE &timer_queue, - ACE_Handler *handler); + int cancellation (TIMER_QUEUE &timer_queue, + ACE_Handler *handler); // This method is called when the timer is canceled protected: @@ -96,17 +98,33 @@ public: // for the Proactor (add to the ease of use of these template // classes). - typedef ACE_Timer_Queue_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_Queue; - typedef ACE_Timer_Queue_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_Queue_Iterator; - - typedef ACE_Timer_List_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_List; - typedef ACE_Timer_List_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_List_Iterator; - - typedef ACE_Timer_Heap_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_Heap; - typedef ACE_Timer_Heap_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_Heap_Iterator; - - typedef ACE_Timer_Wheel_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_Wheel; - typedef ACE_Timer_Wheel_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall> Timer_Wheel_Iterator; + typedef ACE_Timer_Queue_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_Queue; + typedef ACE_Timer_Queue_Iterator_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_Queue_Iterator; + + typedef ACE_Timer_List_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_List; + typedef ACE_Timer_List_Iterator_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_List_Iterator; + + typedef ACE_Timer_Heap_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_Heap; + typedef ACE_Timer_Heap_Iterator_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_Heap_Iterator; + + typedef ACE_Timer_Wheel_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_Wheel; + typedef ACE_Timer_Wheel_Iterator_T<ACE_Handler *, + ACE_Proactor_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> Timer_Wheel_Iterator; ACE_Proactor (size_t number_of_threads = 0, Timer_Queue *tq = 0, diff --git a/ace/Synch_T.h b/ace/Synch_T.h index 82bde833a89..94533b1c0ae 100644 --- a/ace/Synch_T.h +++ b/ace/Synch_T.h @@ -638,15 +638,18 @@ class ACE_MT_SYNCH { public: typedef ACE_Thread_Mutex MUTEX; + typedef ACE_Recursive_Thread_Mutex RECURSIVE_MUTEX; typedef ACE_RW_Thread_Mutex RW_MUTEX; typedef ACE_Condition_Thread_Mutex CONDITION; }; #define ACE_SYNCH_MUTEX ACE_MT_SYNCH::MUTEX +#define ACE_SYNCH_RECURSIVE_MUTEX ACE_MT_SYNCH::RECURSIVE_MUTEX #define ACE_SYNCH_RW_MUTEX ACE_MT_SYNCH::RW_MUTEX #define ACE_SYNCH_CONDITION ACE_MT_SYNCH::CONDITION #else /* Necessary to support broken cfront-based C++ compilers... */ #define ACE_MT_SYNCH ACE_Thread_Mutex, ACE_Condition_Thread_Mutex #define ACE_SYNCH_MUTEX ACE_Thread_Mutex +#define ACE_SYNCH_RECURSIVE_MUTEX ACE_Recursive_Thread_Mutex #define ACE_SYNCH_RW_MUTEX ACE_RW_Thread_Mutex #define ACE_SYNCH_CONDITION ACE_Thread_Condition #endif /* ACE_HAS_TEMPLATE_TYPEDEFS */ @@ -655,6 +658,7 @@ public: #else #define ACE_SYNCH ACE_NULL_SYNCH #define ACE_SYNCH_MUTEX ACE_Null_Mutex +#define ACE_SYNCH_RECURSIVE_MUTEX ACE_Null_Mutex #define ACE_SYNCH_RW_MUTEX ACE_Null_Mutex #define ACE_SYNCH_CONDITION ACE_Null_Condition #endif /* ACE_HAS_THREADS */ diff --git a/ace/Timer_Heap.h b/ace/Timer_Heap.h index a5fd3337bfa..676ed3b352d 100644 --- a/ace/Timer_Heap.h +++ b/ace/Timer_Heap.h @@ -22,10 +22,14 @@ // The following typedef are here for ease of use and backward // compatibility. -typedef ACE_Timer_Heap_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> +typedef ACE_Timer_Heap_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_Heap; -typedef ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> +typedef ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_Heap_Iterator; #endif /* ACE_TIMER_HEAP_H */ diff --git a/ace/Timer_Heap_T.cpp b/ace/Timer_Heap_T.cpp index b0f4df74a0c..3273741b2a7 100644 --- a/ace/Timer_Heap_T.cpp +++ b/ace/Timer_Heap_T.cpp @@ -11,17 +11,17 @@ #define ACE_HEAP_PARENT(X) (X == 0 ? 0 : (((X) - 1) / 2)) #define ACE_HEAP_LCHILD(X) (((X)+(X))+1) -template <class TYPE, class FUNCTOR> -ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR>::ACE_Timer_Heap_Iterator_T (ACE_Timer_Heap_T<TYPE, FUNCTOR> &heap) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Heap_Iterator_T (ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK> &heap) : timer_heap_ (heap) { ACE_TRACE ("ACE_Timer_Heap_Iterator::ACE_Timer_Heap_Iterator"); } -template <class TYPE, class FUNCTOR> int -ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR>::next (ACE_Timer_Node_T<TYPE, FUNCTOR> *&node, - const ACE_Time_Value &cur_time) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, LOCK>::next (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *&node, + const ACE_Time_Value &cur_time) { ACE_TRACE ("ACE_Timer_Heap_Iterator::next"); @@ -37,10 +37,10 @@ ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR>::next (ACE_Timer_Node_T<TYPE, FUNCTOR> } } -template <class TYPE, class FUNCTOR> -ACE_Timer_Heap_T<TYPE, FUNCTOR>::ACE_Timer_Heap_T (size_t size, - int preallocate, - FUNCTOR *upcall_functor) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Heap_T (size_t size, + int preallocate, + FUNCTOR *upcall_functor) : INHERITED (upcall_functor), max_size_ (size), cur_size_ (0), @@ -52,7 +52,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::ACE_Timer_Heap_T (size_t size, ACE_TRACE ("ACE_Timer_Heap::ACE_Timer_Heap"); // Create the heap array. - ACE_NEW (this->heap_, (ACE_Timer_Node_T<TYPE, FUNCTOR> *[size])); + ACE_NEW (this->heap_, (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *[size])); // Create the parallel ACE_NEW (this->timer_ids_, long[size]); @@ -66,7 +66,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::ACE_Timer_Heap_T (size_t size, if (preallocate) { ACE_NEW (this->preallocated_nodes_, - (ACE_Timer_Node_T<TYPE, FUNCTOR>[size])); + (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>[size])); // Add allocated array to set of such arrays for deletion // on cleanup. @@ -86,8 +86,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::ACE_Timer_Heap_T (size_t size, } } -template <class TYPE, class FUNCTOR> -ACE_Timer_Heap_T<TYPE, FUNCTOR>::~ACE_Timer_Heap_T (void) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::~ACE_Timer_Heap_T (void) { ACE_TRACE ("ACE_Timer_Heap::~ACE_Timer_Heap"); delete [] this->heap_; @@ -96,10 +96,10 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::~ACE_Timer_Heap_T (void) // clean up any preallocated timer nodes if (preallocated_nodes_ != 0) { - ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<TYPE, FUNCTOR> *> + ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *> set_iterator (this->preallocated_node_set_); - for (ACE_Timer_Node_T<TYPE, FUNCTOR> **entry = 0; + for (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> **entry = 0; set_iterator.next (entry) !=0; set_iterator.advance ()) delete [] *entry; @@ -107,8 +107,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::~ACE_Timer_Heap_T (void) } -template <class TYPE, class FUNCTOR> int -ACE_Timer_Heap_T<TYPE, FUNCTOR>::pop_freelist (void) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::pop_freelist (void) { ACE_TRACE ("ACE_Timer_Heap::pop_freelist"); @@ -120,8 +120,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::pop_freelist (void) } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::push_freelist (int old_id) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::push_freelist (int old_id) { ACE_TRACE ("ACE_Timer_Heap::push_freelist"); @@ -132,8 +132,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::push_freelist (int old_id) } -template <class TYPE, class FUNCTOR> int -ACE_Timer_Heap_T<TYPE, FUNCTOR>::timer_id (void) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::timer_id (void) { ACE_TRACE ("ACE_Timer_Heap::timer_id"); @@ -144,16 +144,16 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::timer_id (void) // Checks if queue is empty. -template <class TYPE, class FUNCTOR> int -ACE_Timer_Heap_T<TYPE, FUNCTOR>::is_empty (void) const +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::is_empty (void) const { ACE_TRACE ("ACE_Timer_Heap::is_empty"); return this->cur_size_ == 0; } -template <class TYPE, class FUNCTOR> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> & -ACE_Timer_Heap_T<TYPE, FUNCTOR>::iter (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> & +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::iter (void) { return this->iterator_; } @@ -161,16 +161,16 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::iter (void) // Returns earliest time in a non-empty queue. -template <class TYPE, class FUNCTOR> const ACE_Time_Value & -ACE_Timer_Heap_T<TYPE, FUNCTOR>::earliest_time (void) const +template <class TYPE, class FUNCTOR, class LOCK> const ACE_Time_Value & +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::earliest_time (void) const { ACE_TRACE ("ACE_Timer_Heap::earliest_time"); return this->heap_[0]->timer_value_; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::dump (void) const +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::dump (void) const { ACE_TRACE ("ACE_Timer_Heap::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); @@ -193,8 +193,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::copy (int index, ACE_Timer_Node_T<TYPE, FUNCTOR> *moved_node) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::copy (int index, ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *moved_node) { // Insert <moved_node> into its new location in the heap. this->heap_[index] = moved_node; @@ -205,10 +205,10 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::copy (int index, ACE_Timer_Node_T<TYPE, FUNCTOR this->timer_ids_[moved_node->timer_id_] = index; } -template <class TYPE, class FUNCTOR> ACE_Timer_Node_T<TYPE, FUNCTOR> * -ACE_Timer_Heap_T<TYPE, FUNCTOR>::remove (size_t index) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> * +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::remove (size_t index) { - ACE_Timer_Node_T<TYPE, FUNCTOR> *removed_node = this->heap_[index]; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *removed_node = this->heap_[index]; // Return this timer id to the freelist. this->push_freelist (removed_node->timer_id_); @@ -221,7 +221,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::remove (size_t index) if (index < this->cur_size_) { - ACE_Timer_Node_T<TYPE, FUNCTOR> *moved_node = this->heap_[this->cur_size_]; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *moved_node = this->heap_[this->cur_size_]; // Move the end node to the location being removed and update // the corresponding slot in the parallel <timer_ids> array. @@ -240,10 +240,10 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::remove (size_t index) return removed_node; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::reheap_down (ACE_Timer_Node_T<TYPE, FUNCTOR> *moved_node, - size_t index, - size_t child) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::reheap_down (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *moved_node, + size_t index, + size_t child) { // Restore the heap property after a deletion. @@ -270,10 +270,10 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::reheap_down (ACE_Timer_Node_T<TYPE, FUNCTOR> *m this->copy (index, moved_node); } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::reheap_up (ACE_Timer_Node_T<TYPE, FUNCTOR> *moved_node, - size_t index, - size_t parent) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::reheap_up (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *moved_node, + size_t index, + size_t parent) { // Restore the heap property after an insertion. @@ -296,8 +296,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::reheap_up (ACE_Timer_Node_T<TYPE, FUNCTOR> *mov this->copy (index, moved_node); } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::insert (ACE_Timer_Node_T<TYPE, FUNCTOR> *new_node) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::insert (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *new_node) { if (this->cur_size_ + 1 >= max_size_) this->grow_heap (); @@ -309,16 +309,16 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::insert (ACE_Timer_Node_T<TYPE, FUNCTOR> *new_no } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::grow_heap (void) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::grow_heap (void) { // All the containers will double in size from max_size_ size_t new_size = max_size_ * 2; // First grow the heap itself. - ACE_Timer_Node_T<TYPE, FUNCTOR> **new_heap = 0; - ACE_NEW (new_heap, (ACE_Timer_Node_T<TYPE, FUNCTOR> *[new_size])); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> **new_heap = 0; + ACE_NEW (new_heap, (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *[new_size])); ACE_OS::memcpy (new_heap, this->heap_, max_size_ * sizeof *new_heap); delete [] this->heap_; @@ -347,7 +347,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::grow_heap (void) // Create a new array with max_size elements to link in // to existing list. ACE_NEW (this->preallocated_nodes_, - (ACE_Timer_Node_T<TYPE, FUNCTOR>[this->max_size_])); + (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>[this->max_size_])); // Add it to the set for later deletion this->preallocated_node_set_.insert (this->preallocated_nodes_); @@ -365,9 +365,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::grow_heap (void) this->preallocated_nodes_freelist_ = &preallocated_nodes_[0]; else { - ACE_Timer_Node_T<TYPE, FUNCTOR> *previous = this->preallocated_nodes_freelist_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *previous = this->preallocated_nodes_freelist_; - for (ACE_Timer_Node_T<TYPE, FUNCTOR> *current = this->preallocated_nodes_freelist_->next_; + for (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *current = this->preallocated_nodes_freelist_->next_; current != 0; current = current->next_) previous = current; @@ -382,8 +382,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::grow_heap (void) // Reschedule a periodic timer. This function must be called with the // mutex lock held. -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *expired) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *expired) { ACE_TRACE ("ACE_Timer_Heap::reschedule"); @@ -392,15 +392,15 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *ex } -template <class TYPE, class FUNCTOR> ACE_Timer_Node_T<TYPE, FUNCTOR> * -ACE_Timer_Heap_T<TYPE, FUNCTOR>::alloc_node (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> * +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::alloc_node (void) { ACE_Timer_Node *temp; // Only allocate a node if we are *not* using the preallocated heap. if (this->preallocated_nodes_ == 0) ACE_NEW_RETURN (temp, - (ACE_Timer_Node_T<TYPE, FUNCTOR>), + (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>), 0); else { @@ -418,8 +418,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::alloc_node (void) } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Heap_T<TYPE, FUNCTOR>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *node) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *node) { // Only free up a node if we are *not* using the preallocated heap. if (this->preallocated_nodes_ == 0) @@ -435,15 +435,15 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *nod // > 0, the handler will be reinvoked periodically. -template <class TYPE, class FUNCTOR> long -ACE_Timer_Heap_T<TYPE, FUNCTOR>::schedule (const TYPE &type, - const void *act, - const ACE_Time_Value &future_time, - const ACE_Time_Value &interval) +template <class TYPE, class FUNCTOR, class LOCK> long +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::schedule (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) { ACE_TRACE ("ACE_Timer_Heap::schedule"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); if (this->cur_size_ < this->max_size_) { @@ -451,17 +451,17 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::schedule (const TYPE &type, int timer_id = this->timer_id (); // Obtain the memory to the new node. - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->alloc_node (); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->alloc_node (); if (temp) { // Use operator placement new. - new (temp) ACE_Timer_Node_T<TYPE, FUNCTOR> (type, - act, - future_time, - interval, - 0, - timer_id); + new (temp) ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> (type, + act, + future_time, + interval, + 0, + timer_id); this->insert (temp); return timer_id; } @@ -474,13 +474,13 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::schedule (const TYPE &type, // Locate and remove the single timer with a value of <timer_id> from // the timer queue. -template <class TYPE, class FUNCTOR> int -ACE_Timer_Heap_T<TYPE, FUNCTOR>::cancel (long timer_id, - const void **act, - int dont_call) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::cancel (long timer_id, + const void **act, + int dont_call) { ACE_TRACE ("ACE_Timer_Heap::cancel"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); // Locate the ACE_Timer_Node that corresponds to the timer_id. @@ -493,11 +493,11 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::cancel (long timer_id, } else { - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->remove (timer_node_slot); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->remove (timer_node_slot); if (dont_call == 0) // Call the close hook. - this->upcall_functor_.operator () (*this, temp->type_); + this->upcall_functor_.cancellation (*this, temp->type_); if (act != 0) *act = temp->act_; @@ -509,12 +509,12 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::cancel (long timer_id, // Locate and remove all values of <type> from the timer queue. -template <class TYPE, class FUNCTOR> int -ACE_Timer_Heap_T<TYPE, FUNCTOR>::cancel (const TYPE &type, - int dont_call) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>::cancel (const TYPE &type, + int dont_call) { ACE_TRACE ("ACE_Timer_Heap::cancel"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); int number_of_cancellations = 0; @@ -524,15 +524,15 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR>::cancel (const TYPE &type, { if (this->heap_[i]->type_ == type) { - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->remove (i); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->remove (i); number_of_cancellations++; if (dont_call == 0 && number_of_cancellations == 1) // Call the close hook. - this->upcall_functor_.operator () (*this, temp->type_); - + this->upcall_functor_.cancellation (*this, temp->type_); + this->free_node (temp); } else diff --git a/ace/Timer_Heap_T.h b/ace/Timer_Heap_T.h index 45fb7e26b19..2a2780f2137 100644 --- a/ace/Timer_Heap_T.h +++ b/ace/Timer_Heap_T.h @@ -21,11 +21,11 @@ #include "ace/Containers.h" // Forward declaration -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Heap_T; -template <class TYPE, class FUNCTOR> -class ACE_Timer_Heap_Iterator_T : public ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> +class ACE_Timer_Heap_Iterator_T : public ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> // = TITLE // Iterates over an <ACE_Timer_Queue>. // @@ -34,10 +34,10 @@ class ACE_Timer_Heap_Iterator_T : public ACE_Timer_Queue_Iterator_T<TYPE, FUNCTO // the head of the timer queue up by one every time. { public: - ACE_Timer_Heap_Iterator_T (ACE_Timer_Heap_T<TYPE, FUNCTOR> &); + ACE_Timer_Heap_Iterator_T (ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK> &); // Constructor. - virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR> *&timer_node, + virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *&timer_node, const ACE_Time_Value &cur_time); // Pass back the next <timer_node> that hasn't been seen yet, if its // <time_value_> <= <cur_time>. In addition, moves the timer queue @@ -45,12 +45,12 @@ public: // seen, else 1. protected: - ACE_Timer_Heap_T<TYPE, FUNCTOR> &timer_heap_; + ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK> &timer_heap_; // Pointer to the <ACE_Timer_Heap> that we are iterating over. }; -template <class TYPE, class FUNCTOR> -class ACE_Timer_Heap_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> +class ACE_Timer_Heap_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> // = TITLE // Provides a very fast and predictable timer implementation. // @@ -66,10 +66,10 @@ class ACE_Timer_Heap_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR> // systems. { public: - typedef ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR> HEAP_ITERATOR; - friend class ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR>; + typedef ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, LOCK> HEAP_ITERATOR; + friend class ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, LOCK>; - typedef ACE_Timer_Queue_T<TYPE, FUNCTOR> INHERITED; + typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> INHERITED; // = Initialization and termination methods. ACE_Timer_Heap_T (size_t size = ACE_DEFAULT_TIMERS, @@ -128,27 +128,27 @@ public: // Dump the state of an object. protected: - virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *); + virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *); // Reschedule an "interval" <ACE_Timer_Node>. - virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> &iter (void); + virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> &iter (void); // Returns a pointer to this <ACE_Timer_Queue>'s iterator. - virtual ACE_Timer_Node_T<TYPE, FUNCTOR> *alloc_node (void); + virtual ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *alloc_node (void); // Factory method that allocates a new node (uses operator new if // we're *not* preallocating, otherwise uses an internal freelist). - virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *); + virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *); // Factory method that frees a previously allocated node (uses // operatord delete if we're *not* preallocating, otherwise uses an // internal freelist). private: - ACE_Timer_Node_T<TYPE, FUNCTOR> *remove (size_t index); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *remove (size_t index); // Remove and return the <index>th <ACE_Timer_Node> and restore the // heap property. - void insert (ACE_Timer_Node_T<TYPE, FUNCTOR> *new_node); + void insert (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *new_node); // Insert <new_node> into the heap and restore the heap property. void grow_heap (void); @@ -156,17 +156,17 @@ private: // If preallocation is used, will also double the size of the // preallocated array of ACE_Timer_Nodes. - void reheap_up (ACE_Timer_Node_T<TYPE, FUNCTOR> *new_node, + void reheap_up (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *new_node, size_t index, size_t parent); // Restore the heap property, starting at <index>. - void reheap_down (ACE_Timer_Node_T<TYPE, FUNCTOR> *moved_node, + void reheap_down (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *moved_node, size_t index, size_t child); // Restore the heap property, starting at <index>. - void copy (int index, ACE_Timer_Node_T<TYPE, FUNCTOR> *moved_node); + void copy (int index, ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *moved_node); // Copy <moved_node> into the <index> slot of <heap_> and move // <index> into the corresponding slot in the <timer_id_> array. @@ -191,7 +191,7 @@ private: HEAP_ITERATOR iterator_; // Iterator used to expire timers. - ACE_Timer_Node_T<TYPE, FUNCTOR> **heap_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> **heap_; // Current contents of the Heap, which is organized as a "heap" of // <ACE_Timer_Node> *'s. In this context, a heap is a "partially // ordered, almost complete" binary tree, which is stored in an @@ -211,23 +211,23 @@ private: // "Pointer" to the first element in the freelist contained within // the <timer_ids_> array, which is organized as a stack. - ACE_Timer_Node_T<TYPE, FUNCTOR> *preallocated_nodes_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *preallocated_nodes_; // If this is non-0, then we preallocate <max_size_> number of // <ACE_Timer_Node> objects in order to reduce dynamic allocation // costs. In auto-growing implementation, this points to the // last array of nodes allocated. - ACE_Timer_Node_T<TYPE, FUNCTOR> *preallocated_nodes_freelist_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *preallocated_nodes_freelist_; // This points to the head of the <preallocated_nodes_> freelist, // which is organized as a stack. - ACE_Unbounded_Set<ACE_Timer_Node_T<TYPE, FUNCTOR> *> preallocated_node_set_; + ACE_Unbounded_Set<ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *> preallocated_node_set_; // Set of pointers to the arrays of preallocated timer nodes. // Used to delete the allocated memory when required. // = Don't allow these operations for now. - ACE_Timer_Heap_T (const ACE_Timer_Heap_T<TYPE, FUNCTOR> &); - void operator= (const ACE_Timer_Heap_T<TYPE, FUNCTOR> &); + ACE_Timer_Heap_T (const ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK> &); + void operator= (const ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK> &); }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) diff --git a/ace/Timer_List.h b/ace/Timer_List.h index cd5e8c0f751..228a6f21a78 100644 --- a/ace/Timer_List.h +++ b/ace/Timer_List.h @@ -22,10 +22,14 @@ // The following typedef are here for ease of use and backward // compatibility. -typedef ACE_Timer_List_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> +typedef ACE_Timer_List_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_List; -typedef ACE_Timer_List_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> +typedef ACE_Timer_List_Iterator_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_List_Iterator; #endif /* ACE_TIMER_LIST_H */ diff --git a/ace/Timer_List_T.cpp b/ace/Timer_List_T.cpp index 4cb32a6f063..33719b8a38e 100644 --- a/ace/Timer_List_T.cpp +++ b/ace/Timer_List_T.cpp @@ -7,16 +7,16 @@ #include "ace/Timer_List_T.h" -template <class TYPE, class FUNCTOR> -ACE_Timer_List_Iterator_T<TYPE, FUNCTOR>::ACE_Timer_List_Iterator_T (ACE_Timer_List_T<TYPE, FUNCTOR> &list) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_List_Iterator_T (ACE_Timer_List_T<TYPE, FUNCTOR, LOCK> &list) : timer_list_ (list) { } -template <class TYPE, class FUNCTOR> int -ACE_Timer_List_Iterator_T<TYPE, FUNCTOR>::next (ACE_Timer_Node_T<TYPE, FUNCTOR> *&node, - const ACE_Time_Value &cur_time) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>::next (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *&node, + const ACE_Time_Value &cur_time) { if (this->timer_list_.head_ == 0 || this->timer_list_.head_->timer_value_ > cur_time) @@ -31,17 +31,17 @@ ACE_Timer_List_Iterator_T<TYPE, FUNCTOR>::next (ACE_Timer_Node_T<TYPE, FUNCTOR> ACE_ALLOC_HOOK_DEFINE(ACE_Timer_List_T) -template <class TYPE, class FUNCTOR> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> & -ACE_Timer_List_T<TYPE, FUNCTOR>::iter (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> & +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::iter (void) { return this->iterator_; } // Create an empty list. -template <class TYPE, class FUNCTOR> -ACE_Timer_List_T<TYPE, FUNCTOR>::ACE_Timer_List_T (FUNCTOR *upcall_functor) - : ACE_Timer_Queue_T<TYPE, FUNCTOR> (upcall_functor), +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_List_T (FUNCTOR *upcall_functor) + : ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> (upcall_functor), head_ (0), iterator_ (*this), timer_id_ (0) @@ -52,21 +52,21 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::ACE_Timer_List_T (FUNCTOR *upcall_functor) // Checks if list is empty. -template <class TYPE, class FUNCTOR> int -ACE_Timer_List_T<TYPE, FUNCTOR>::is_empty (void) const +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::is_empty (void) const { ACE_TRACE ("ACE_Timer_List::is_empty"); return this->head_ == 0; } -template <class TYPE, class FUNCTOR> ACE_Timer_Node_T<TYPE, FUNCTOR> * -ACE_Timer_List_T<TYPE, FUNCTOR>::alloc_node (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> * +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::alloc_node (void) { - return new ACE_Timer_Node_T<TYPE, FUNCTOR>; + return new ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_List_T<TYPE, FUNCTOR>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *node) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *node) { delete node; } @@ -74,8 +74,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *nod // Returns earliest time in a non-empty list. -template <class TYPE, class FUNCTOR> const ACE_Time_Value & -ACE_Timer_List_T<TYPE, FUNCTOR>::earliest_time (void) const +template <class TYPE, class FUNCTOR, class LOCK> const ACE_Time_Value & +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::earliest_time (void) const { ACE_TRACE ("ACE_Timer_List::earliest_time"); return this->head_->timer_value_; @@ -83,25 +83,25 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::earliest_time (void) const // Remove all remaining items in the list. -template <class TYPE, class FUNCTOR> -ACE_Timer_List_T<TYPE, FUNCTOR>::~ACE_Timer_List_T (void) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::~ACE_Timer_List_T (void) { ACE_TRACE ("ACE_Timer_List::~ACE_Timer_List"); - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_)); + ACE_MT (ACE_GUARD (LOCK, ace_mon, this->lock_)); - ACE_Timer_Node_T<TYPE, FUNCTOR> *curr = this->head_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *curr = this->head_; while (curr != 0) { - ACE_Timer_Node_T<TYPE, FUNCTOR> *next = curr->next_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *next = curr->next_; this->free_node (curr); curr = next; } } -template <class TYPE, class FUNCTOR> void -ACE_Timer_List_T<TYPE, FUNCTOR>::dump (void) const +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::dump (void) const { ACE_TRACE ("ACE_Timer_List::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); @@ -114,8 +114,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::dump (void) const // mutex lock held. -template <class TYPE, class FUNCTOR> void -ACE_Timer_List_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *expired) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *expired) { ACE_TRACE ("ACE_Timer_List::reschedule"); if (this->is_empty () @@ -126,8 +126,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *ex } else { - ACE_Timer_Node_T<TYPE, FUNCTOR> *prev = this->head_; - ACE_Timer_Node_T<TYPE, FUNCTOR> *after = this->head_->next_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *prev = this->head_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *after = this->head_->next_; // Locate the proper position in the queue. @@ -147,14 +147,14 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *ex // is > 0, the handler will be reinvoked periodically. -template <class TYPE, class FUNCTOR> long -ACE_Timer_List_T<TYPE, FUNCTOR>::schedule (const TYPE &type, - const void *act, - const ACE_Time_Value &future_time, - const ACE_Time_Value &interval) +template <class TYPE, class FUNCTOR, class LOCK> long +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::schedule (const TYPE &type, + const void *act, + const ACE_Time_Value &future_time, + const ACE_Time_Value &interval) { ACE_TRACE ("ACE_Timer_List::schedule"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); // Increment the sequence number (it will wrap around). long timer_id = this->timer_id (); @@ -162,15 +162,15 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::schedule (const TYPE &type, if (this->is_empty () || future_time < this->earliest_time ()) { // Place at the beginning of the list. - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->alloc_node (); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->alloc_node (); // Use operator placement new. - this->head_ = new (temp) ACE_Timer_Node_T<TYPE, FUNCTOR> (type, - act, - future_time, - interval, - this->head_, - timer_id); + this->head_ = new (temp) ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> (type, + act, + future_time, + interval, + this->head_, + timer_id); return timer_id; } @@ -178,8 +178,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::schedule (const TYPE &type, // ascending order of absolute time to expire). else { - ACE_Timer_Node_T<TYPE, FUNCTOR> *prev = this->head_; - ACE_Timer_Node_T<TYPE, FUNCTOR> *after = this->head_->next_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *prev = this->head_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *after = this->head_->next_; while (after != 0 && future_time > after->timer_value_) { @@ -187,22 +187,22 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::schedule (const TYPE &type, after = after->next_; } - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->alloc_node (); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->alloc_node (); // Use operator placement new. - prev->next_ = new (temp) ACE_Timer_Node_T<TYPE, FUNCTOR> (type, - act, - future_time, - interval, - after, - timer_id); + prev->next_ = new (temp) ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> (type, + act, + future_time, + interval, + after, + timer_id); return timer_id; } } -template <class TYPE, class FUNCTOR> int -ACE_Timer_List_T<TYPE, FUNCTOR>::timer_id (void) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::timer_id (void) { this->timer_id_++; @@ -217,16 +217,16 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::timer_id (void) // <timer_id> from the timer queue. -template <class TYPE, class FUNCTOR> int -ACE_Timer_List_T<TYPE, FUNCTOR>::cancel (long timer_id, - const void **act, - int dont_call) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::cancel (long timer_id, + const void **act, + int dont_call) { ACE_TRACE ("ACE_Timer_List::cancel"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); - ACE_Timer_Node_T<TYPE, FUNCTOR> *prev = 0; - ACE_Timer_Node_T<TYPE, FUNCTOR> *curr = 0; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *prev = 0; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *curr = 0; // Try to locate the ACE_Timer_Node that matches the timer_id. @@ -246,9 +246,7 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::cancel (long timer_id, *act = curr->act_; if (dont_call == 0) - // This calls the correct operator () on the functor (the one with - // two args) - this->upcall_functor_.operator () (*this, curr->type_); + this->upcall_functor_.cancellation (*this, curr->type_); this->free_node (curr); return 1; } @@ -259,15 +257,15 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::cancel (long timer_id, // Locate and remove all values of <handler> from the timer queue. -template <class TYPE, class FUNCTOR> int -ACE_Timer_List_T<TYPE, FUNCTOR>::cancel (const TYPE &type, - int dont_call) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>::cancel (const TYPE &type, + int dont_call) { ACE_TRACE ("ACE_Timer_List::cancel"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); - ACE_Timer_Node_T<TYPE, FUNCTOR> *prev = 0; - ACE_Timer_Node_T<TYPE, FUNCTOR> *curr = this->head_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *prev = 0; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *curr = this->head_; int number_of_cancellations = 0; @@ -279,9 +277,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR>::cancel (const TYPE &type, if (dont_call == 0 && number_of_cancellations == 1) - // This calls the correct operator () on the functor (the one with - // two args) - this->upcall_functor_.operator () (*this, curr->type_); + this->upcall_functor_.cancellation (*this, curr->type_); + if (prev == 0) { this->head_ = curr->next_; diff --git a/ace/Timer_List_T.h b/ace/Timer_List_T.h index fd56b93c2e8..b164fff5aa6 100644 --- a/ace/Timer_List_T.h +++ b/ace/Timer_List_T.h @@ -20,11 +20,11 @@ #include "ace/Timer_Queue.h" // Forward declaration. -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_List_T; -template <class TYPE, class FUNCTOR> -class ACE_Timer_List_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> +class ACE_Timer_List_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR, LOCK> // = TITLE // Iterates over an <ACE_Timer_Queue>. // @@ -33,10 +33,10 @@ class ACE_Timer_List_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCT // the head of the timer queue up by one every time. { public: - ACE_Timer_List_Iterator_T (ACE_Timer_List_T<TYPE, FUNCTOR> &); + ACE_Timer_List_Iterator_T (ACE_Timer_List_T<TYPE, FUNCTOR, LOCK> &); // Constructor. - virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR> *&timer_node, + virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *&timer_node, const ACE_Time_Value &cur_time); // Pass back the next <timer_node> that hasn't been seen yet, if its // <time_value_> <= <cur_time>. In addition, moves the timer queue @@ -44,12 +44,12 @@ public: // seen, else 1. protected: - ACE_Timer_List_T<TYPE, FUNCTOR> &timer_list_; + ACE_Timer_List_T<TYPE, FUNCTOR, LOCK> &timer_list_; // Pointer to the <ACE_Timer_List> that we are iterating over. }; -template <class TYPE, class FUNCTOR> -class ACE_Timer_List_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> +class ACE_Timer_List_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> // = TITLE // Provides a simple implementation of timers. // @@ -69,13 +69,13 @@ class ACE_Timer_List_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR> // <ACE_Timer_List>. { public: - typedef ACE_Timer_List_Iterator_T<TYPE, FUNCTOR> LIST_ITERATOR; + typedef ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK> LIST_ITERATOR; // Type of iterator - friend class ACE_Timer_List_Iterator_T<TYPE, FUNCTOR>; + friend class ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>; // Iterator is a friend - typedef ACE_Timer_Queue_T<TYPE, FUNCTOR> INHERITED; + typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> INHERITED; // Type inherited from // = Initialization and termination methods. @@ -131,10 +131,10 @@ public: // Dump the state of an object. protected: - virtual ACE_Timer_Node_T<TYPE, FUNCTOR> *alloc_node (void); + virtual ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *alloc_node (void); // Factory method that allocates a new node (uses operator new). - virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *); + virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *); // Factory method that frees a previously allocated node (uses // operator delete). @@ -145,13 +145,13 @@ private: // timer id returned from this method will never == -1 to avoid // conflicts with other failure return values. - virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *); + virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *); // Reschedule an "interval" <ACE_Timer_Node>. - virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> &iter (void); + virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> &iter (void); // Returns a pointer to this <ACE_Timer_Queue>'s iterator. - ACE_Timer_Node_T<TYPE, FUNCTOR> *head_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *head_; // Pointer to linked list of <ACE_Timer_Handles>. LIST_ITERATOR iterator_; @@ -163,8 +163,8 @@ private: // method. // = Don't allow these operations for now. - ACE_Timer_List_T (const ACE_Timer_List_T<TYPE, FUNCTOR> &); - void operator= (const ACE_Timer_List_T<TYPE, FUNCTOR> &); + ACE_Timer_List_T (const ACE_Timer_List_T<TYPE, FUNCTOR, LOCK> &); + void operator= (const ACE_Timer_List_T<TYPE, FUNCTOR, LOCK> &); }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) diff --git a/ace/Timer_Queue.cpp b/ace/Timer_Queue.cpp index 5a3033170ad..e237a5d8b07 100644 --- a/ace/Timer_Queue.cpp +++ b/ace/Timer_Queue.cpp @@ -10,10 +10,10 @@ #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ int -ACE_Event_Handler_Handle_Timeout_Upcall::operator () (TIMER_QUEUE &timer_queue, - ACE_Event_Handler *handler, - const void *act, - const ACE_Time_Value &cur_time) +ACE_Event_Handler_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *act, + const ACE_Time_Value &cur_time) { // Upcall to the <handler>s handle_timeout method if (handler->handle_timeout (cur_time, act) == -1) @@ -24,8 +24,8 @@ ACE_Event_Handler_Handle_Timeout_Upcall::operator () (TIMER_QUEUE &timer_queue, int -ACE_Event_Handler_Handle_Timeout_Upcall::operator () (TIMER_QUEUE &timer_queue, - ACE_Event_Handler *handler) +ACE_Event_Handler_Handle_Timeout_Upcall::cancellation (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler) { ACE_UNUSED_ARG (timer_queue); @@ -36,16 +36,16 @@ ACE_Event_Handler_Handle_Timeout_Upcall::operator () (TIMER_QUEUE &timer_queue, } #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> *>; -template class ACE_Node<ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> *>; -template class ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> *>; -template class ACE_Timer_Heap_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_List_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_List_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_Queue_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_Queue_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_Wheel_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; -template class ACE_Timer_Wheel_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall>; +template class ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> *>; +template class ACE_Node<ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> *>; +template class ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> *>; +template class ACE_Timer_Heap_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Node_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_List_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_List_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Queue_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Queue_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Wheel_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Timer_Wheel_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/ace/Timer_Queue.h b/ace/Timer_Queue.h index d67b643df92..42bf2fb5248 100644 --- a/ace/Timer_Queue.h +++ b/ace/Timer_Queue.h @@ -17,6 +17,7 @@ #if !defined (ACE_TIMER_QUEUE_H) #define ACE_TIMER_QUEUE_H +#include "ace/Synch.h" #include "ace/Timer_Queue_T.h" class ACE_Export ACE_Event_Handler_Handle_Timeout_Upcall @@ -28,17 +29,19 @@ class ACE_Export ACE_Event_Handler_Handle_Timeout_Upcall // Queue to call <handle_timeout> on ACE_Event_Handlers. { public: - typedef ACE_Timer_Queue_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> + typedef ACE_Timer_Queue_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> TIMER_QUEUE; - int operator () (TIMER_QUEUE &timer_queue, - ACE_Event_Handler *handler, - const void *arg, - const ACE_Time_Value &cur_time); + int timeout (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler, + const void *arg, + const ACE_Time_Value &cur_time); // This method is called when the timer expires - int operator () (TIMER_QUEUE &timer_queue, - ACE_Event_Handler *handler); + int cancellation (TIMER_QUEUE &timer_queue, + ACE_Event_Handler *handler); // This method is called when the timer is canceled }; @@ -46,15 +49,18 @@ public: // compatibility. typedef ACE_Timer_Node_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall> + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_Node; typedef ACE_Timer_Queue_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall> + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_Queue; typedef ACE_Timer_Queue_Iterator_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall> + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_Queue_Iterator; #endif /* ACE_TIMER_QUEUE_H */ diff --git a/ace/Timer_Queue_T.cpp b/ace/Timer_Queue_T.cpp index 986c08a9777..a18440406ff 100644 --- a/ace/Timer_Queue_T.cpp +++ b/ace/Timer_Queue_T.cpp @@ -13,8 +13,8 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Timer_Node_T) -template <class TYPE, class FUNCTOR> void -ACE_Timer_Node_T<TYPE, FUNCTOR>::dump (void) const +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>::dump (void) const { ACE_TRACE ("ACE_Timer_Node::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); @@ -28,19 +28,19 @@ ACE_Timer_Node_T<TYPE, FUNCTOR>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -template <class TYPE, class FUNCTOR> -ACE_Timer_Node_T<TYPE, FUNCTOR>::ACE_Timer_Node_T (void) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Node_T (void) { ACE_TRACE ("ACE_Timer_Node::ACE_Timer_Node"); } -template <class TYPE, class FUNCTOR> -ACE_Timer_Node_T<TYPE, FUNCTOR>::ACE_Timer_Node_T (const TYPE &type, - const void *a, - const ACE_Time_Value &t, - const ACE_Time_Value &i, - ACE_Timer_Node_T<TYPE, FUNCTOR> *n, - long timer_id) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Node_T (const TYPE &type, + const void *a, + const ACE_Time_Value &t, + const ACE_Time_Value &i, + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *n, + long timer_id) : type_ (type), act_ (a), timer_value_ (t), @@ -52,14 +52,14 @@ ACE_Timer_Node_T<TYPE, FUNCTOR>::ACE_Timer_Node_T (const TYPE &type, ACE_TRACE ("ACE_Timer_Node::ACE_Timer_Node"); } -template <class TYPE, class FUNCTOR> -ACE_Timer_Node_T<TYPE, FUNCTOR>::ACE_Timer_Node_T (const TYPE &type, - const void *a, - const ACE_Time_Value &t, - const ACE_Time_Value &i, - ACE_Timer_Node_T<TYPE, FUNCTOR> *p, - ACE_Timer_Node_T<TYPE, FUNCTOR> *n, - long timer_id) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Node_T (const TYPE &type, + const void *a, + const ACE_Time_Value &t, + const ACE_Time_Value &i, + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *p, + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *n, + long timer_id) : type_ (type), act_ (a), timer_value_ (t), @@ -72,13 +72,13 @@ ACE_Timer_Node_T<TYPE, FUNCTOR>::ACE_Timer_Node_T (const TYPE &type, } -template <class TYPE, class FUNCTOR> -ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR>::ACE_Timer_Queue_Iterator_T (void) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Queue_Iterator_T (void) { } -template <class TYPE, class FUNCTOR> -ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR>::~ACE_Timer_Queue_Iterator_T (void) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK>::~ACE_Timer_Queue_Iterator_T (void) { } @@ -90,11 +90,11 @@ ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR>::~ACE_Timer_Queue_Iterator_T (void) // Time_Value type stored in the Timer_Queue type itself. If some // external lock isn't held we'll have reentrancy problems! -template <class TYPE, class FUNCTOR> ACE_Time_Value * -ACE_Timer_Queue_T<TYPE, FUNCTOR>::calculate_timeout (ACE_Time_Value *max_wait_time) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Time_Value * +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::calculate_timeout (ACE_Time_Value *max_wait_time) { ACE_TRACE ("ACE_Timer_List::calculate_timeout"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, max_wait_time)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, max_wait_time)); if (this->is_empty ()) // Nothing on the Timer_Queue, so use whatever the caller gave us. @@ -127,8 +127,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR>::calculate_timeout (ACE_Time_Value *max_wait_ti } } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Queue_T<TYPE, FUNCTOR>::dump (void) const +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::dump (void) const { ACE_TRACE ("ACE_Timer_Queue::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); @@ -137,8 +137,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR>::dump (void) const ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -template <class TYPE, class FUNCTOR> -ACE_Timer_Queue_T<TYPE, FUNCTOR>::ACE_Timer_Queue_T (FUNCTOR *upcall_functor) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Queue_T (FUNCTOR *upcall_functor) : gettimeofday_ (ACE_OS::gettimeofday), upcall_functor_ (upcall_functor == 0 ? *(new FUNCTOR) : *upcall_functor), delete_upcall_functor_ (upcall_functor == 0), @@ -147,8 +147,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR>::ACE_Timer_Queue_T (FUNCTOR *upcall_functor) ACE_TRACE ("ACE_Timer_Queue::ACE_Timer_Queue"); } -template <class TYPE, class FUNCTOR> -ACE_Timer_Queue_T<TYPE, FUNCTOR>::~ACE_Timer_Queue_T (void) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::~ACE_Timer_Queue_T (void) { // Cleanup the functor on the way out if (delete_upcall_functor_) @@ -160,15 +160,15 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR>::~ACE_Timer_Queue_T (void) // Run the <handle_timeout> method for all Timers whose values are <= // <cur_time>. -template <class TYPE, class FUNCTOR> int -ACE_Timer_Queue_T<TYPE, FUNCTOR>::expire (const ACE_Time_Value &cur_time) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::expire (const ACE_Time_Value &cur_time) { ACE_TRACE ("ACE_Timer_List::expire"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); int number_of_timers_expired = 0; - ACE_Timer_Node_T<TYPE, FUNCTOR> *expired; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *expired; // Keep looping while there are timers remaining and the earliest // timer is <= the <cur_time> passed in to the method. @@ -209,44 +209,4 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR>::expire (const ACE_Time_Value &cur_time) return number_of_timers_expired; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Queue_T<TYPE, FUNCTOR>::upcall (TYPE &type, - const void *act, - const ACE_Time_Value &cur_time) -{ - // This calls the correct operator () on the functor (the one with - // four args) - this->upcall_functor_.operator () (*this, type, act, cur_time); -} - - -template <class TYPE, class FUNCTOR> ACE_Time_Value -ACE_Timer_Queue_T<TYPE, FUNCTOR>::gettimeofday (void) -{ - // Invoke gettimeofday via pointer to function. - return gettimeofday_ (); -} - -template <class TYPE, class FUNCTOR> void -ACE_Timer_Queue_T<TYPE, FUNCTOR>::gettimeofday (ACE_Time_Value (*gettimeofday)(void)) -{ - gettimeofday_ = gettimeofday; -} - -#if defined (ACE_MT_SAFE) - -template <class TYPE, class FUNCTOR> ACE_Recursive_Thread_Mutex & -ACE_Timer_Queue_T<TYPE, FUNCTOR>::lock (void) -{ - return this->lock_; -} - -#endif /* ACE_MT_SAFE */ - -template <class TYPE, class FUNCTOR> FUNCTOR & -ACE_Timer_Queue_T<TYPE, FUNCTOR>::upcall_functor (void) -{ - return this->upcall_functor_; -} - #endif /* ACE_TIMER_QUEUE_T_C*/ diff --git a/ace/Timer_Queue_T.h b/ace/Timer_Queue_T.h index f79868e194c..7c396a624fc 100644 --- a/ace/Timer_Queue_T.h +++ b/ace/Timer_Queue_T.h @@ -18,53 +18,52 @@ #define ACE_TIMER_QUEUE_T_H #include "ace/Time_Value.h" -#include "ace/Synch.h" // Forward declarations. -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Queue_T; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_List_T; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_List_Iterator_T; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Heap_T; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Heap_Iterator_T; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Wheel_T; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Wheel_Iterator_T; // This should be nested within the ACE_Timer_Queue class but some C++ // compilers still don't like this... -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Node_T // = TITLE // Maintains the state associated with a Timer entry. { // = The use of friends should be replaced with accessors... - friend class ACE_Timer_Queue_T<TYPE, FUNCTOR>; - friend class ACE_Timer_List_T<TYPE, FUNCTOR>; - friend class ACE_Timer_List_Iterator_T<TYPE, FUNCTOR>; - friend class ACE_Timer_Heap_T<TYPE, FUNCTOR>; - friend class ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR>; - friend class ACE_Timer_Wheel_T<TYPE, FUNCTOR>; - friend class ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR>; + friend class ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>; + friend class ACE_Timer_List_T<TYPE, FUNCTOR, LOCK>; + friend class ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, LOCK>; + friend class ACE_Timer_Heap_T<TYPE, FUNCTOR, LOCK>; + friend class ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, LOCK>; + friend class ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>; + friend class ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, LOCK>; // = Initialization methods. ACE_Timer_Node_T (const TYPE &type, const void *a, const ACE_Time_Value &t, const ACE_Time_Value &i, - ACE_Timer_Node_T<TYPE, FUNCTOR> *n, + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *n, long timer_id); // Constructor. @@ -72,8 +71,8 @@ class ACE_Timer_Node_T const void *a, const ACE_Time_Value &t, const ACE_Time_Value &i, - ACE_Timer_Node_T<TYPE, FUNCTOR> *p, - ACE_Timer_Node_T<TYPE, FUNCTOR> *n, + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *p, + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *n, long timer_id); // Constructor for the doubly linked list version. @@ -94,10 +93,10 @@ class ACE_Timer_Node_T // If this is a periodic timer this holds the time until the next // timeout. - ACE_Timer_Node_T<TYPE, FUNCTOR> *prev_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *prev_; // Pointer to previous timer. - ACE_Timer_Node_T<TYPE, FUNCTOR> *next_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *next_; // Pointer to next timer. long timer_id_; @@ -110,7 +109,7 @@ class ACE_Timer_Node_T // Dump the state of an TYPE. }; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Queue_Iterator_T // = TITLE // Generic interfae for iterating over a subclass of @@ -128,7 +127,7 @@ public: virtual ~ACE_Timer_Queue_Iterator_T (void); // Destructor. - virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR> *&timer_node, + virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *&timer_node, const ACE_Time_Value &cur_time) = 0; // Pass back the next <timer_node> that hasn't been seen yet, if its // <time_value_> <= <cur_time>. In addition, moves the timer queue @@ -136,7 +135,7 @@ public: // seen, else 1. }; -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Queue_T // = TITLE // Provides an interface to timers. @@ -147,7 +146,7 @@ class ACE_Timer_Queue_T // and <ACE_Timer_Heap>. { public: - typedef ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> ITERATOR; + typedef ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> ITERATOR; // Type of Iterator // = Initialization and termination methods. @@ -227,10 +226,8 @@ public: void timer_skew (const ACE_Time_Value &skew); const ACE_Time_Value &timer_skew (void) const; -#if defined (ACE_MT_SAFE) - ACE_Recursive_Thread_Mutex &lock (void); + LOCK &lock (void); // Synchronization variable used by the queue -#endif /* ACE_MT_SAFE */ FUNCTOR &upcall_functor (void); // Accessor to the upcall functor @@ -249,22 +246,20 @@ protected: // This method will call the <functor> with the <type>, <act> and // <time> - virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *) = 0; + virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *) = 0; // Reschedule an "interval" <ACE_Timer_Node>. virtual ITERATOR &iter (void) = 0; // Returns a pointer to this <ACE_Timer_Queue>'s iterator. - virtual ACE_Timer_Node_T<TYPE, FUNCTOR> *alloc_node (void) = 0; + virtual ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *alloc_node (void) = 0; // Factory method that allocates a new node. - virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *) = 0; + virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *) = 0; // Factory method that frees a previously allocated node. -#if defined (ACE_MT_SAFE) - ACE_Recursive_Thread_Mutex lock_; - // Synchronization variable for the MT_SAFE <ACE_Timer_Queue>. -#endif /* ACE_MT_SAFE */ + LOCK lock_; + // Synchronization variable for <ACE_Timer_Queue>. ACE_Time_Value (*gettimeofday_)(void); // Pointer to function that returns the current time of day. @@ -283,8 +278,8 @@ private: // Adjusts for timer skew in various clocks. // = Don't allow these operations for now. - ACE_Timer_Queue_T (const ACE_Timer_Queue_T<TYPE, FUNCTOR> &); - void operator= (const ACE_Timer_Queue_T<TYPE, FUNCTOR> &); + ACE_Timer_Queue_T (const ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> &); + void operator= (const ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> &); }; #if defined (__ACE_INLINE__) diff --git a/ace/Timer_Queue_T.i b/ace/Timer_Queue_T.i index a69b5b3d284..4778691bb72 100644 --- a/ace/Timer_Queue_T.i +++ b/ace/Timer_Queue_T.i @@ -3,23 +3,58 @@ // Timer_Queue_T.i -template <class TYPE, class FUNCTOR> ACE_INLINE void -ACE_Timer_Queue_T<TYPE, FUNCTOR>::timer_skew (const ACE_Time_Value &skew) +template <class TYPE, class FUNCTOR, class LOCK> ACE_INLINE void +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::timer_skew (const ACE_Time_Value &skew) { timer_skew_ = skew; } -template <class TYPE, class FUNCTOR> ACE_INLINE const ACE_Time_Value & -ACE_Timer_Queue_T<TYPE, FUNCTOR>::timer_skew (void) const +template <class TYPE, class FUNCTOR, class LOCK> ACE_INLINE const ACE_Time_Value & +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::timer_skew (void) const { return timer_skew_; } -template <class TYPE, class FUNCTOR> ACE_INLINE int -ACE_Timer_Queue_T<TYPE, FUNCTOR>::expire (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_INLINE int +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::expire (void) { if (!this->is_empty ()) return this->expire (this->gettimeofday () + timer_skew_); else return 0; } + +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::upcall (TYPE &type, + const void *act, + const ACE_Time_Value &cur_time) +{ + this->upcall_functor_.timeout (*this, type, act, cur_time); +} + + +template <class TYPE, class FUNCTOR, class LOCK> ACE_Time_Value +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::gettimeofday (void) +{ + // Invoke gettimeofday via pointer to function. + return gettimeofday_ (); +} + +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::gettimeofday (ACE_Time_Value (*gettimeofday)(void)) +{ + gettimeofday_ = gettimeofday; +} + +template <class TYPE, class FUNCTOR, class LOCK> LOCK & +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::lock (void) +{ + return this->lock_; +} + +template <class TYPE, class FUNCTOR, class LOCK> FUNCTOR & +ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK>::upcall_functor (void) +{ + return this->upcall_functor_; +} + diff --git a/ace/Timer_Wheel.h b/ace/Timer_Wheel.h index 94ea668f09b..8f988afe117 100644 --- a/ace/Timer_Wheel.h +++ b/ace/Timer_Wheel.h @@ -21,10 +21,14 @@ // The following typedef are here for ease of use and backward // compatibility. -typedef ACE_Timer_Wheel_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> +typedef ACE_Timer_Wheel_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_Wheel; -typedef ACE_Timer_Wheel_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall> +typedef ACE_Timer_Wheel_Iterator_T<ACE_Event_Handler *, + ACE_Event_Handler_Handle_Timeout_Upcall, + ACE_SYNCH_RECURSIVE_MUTEX> ACE_Timer_Wheel_Iterator; #endif /* ACE_TIMER_WHEEL_H */ diff --git a/ace/Timer_Wheel_T.cpp b/ace/Timer_Wheel_T.cpp index a50d534dbf3..61129ada571 100644 --- a/ace/Timer_Wheel_T.cpp +++ b/ace/Timer_Wheel_T.cpp @@ -5,29 +5,29 @@ #include "ace/Timer_Wheel_T.h" -template <class TYPE, class FUNCTOR> -ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR>::ACE_Timer_Wheel_Iterator_T (ACE_Timer_Wheel_T<TYPE, FUNCTOR> &wheel) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Wheel_Iterator_T (ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK> &wheel) : timer_wheel_ (wheel) { } -template <class TYPE, class FUNCTOR> int -ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR>::next (ACE_Timer_Node_T<TYPE, FUNCTOR> *&node, - const ACE_Time_Value &cur_time) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, LOCK>::next (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *&node, + const ACE_Time_Value &cur_time) { if (this->timer_wheel_.wheel_[this->pos_]->next_ == this->timer_wheel_.wheel_[this->pos_] - || this->timer_wheel_.wheel_[this->pos_]->next_->timer_value_ > this->time_) - { - ACE_Time_Value et = this->timer_wheel_.earliest_time (); + || this->timer_wheel_.wheel_[this->pos_]->next_->timer_value_ > this->time_) + { + ACE_Time_Value et = this->timer_wheel_.earliest_time (); - if (this->timer_wheel_.size_ == 0 || et > cur_time) - return 0; + if (this->timer_wheel_.size_ == 0 || et > cur_time) + return 0; - this->pos_ = (et.usec () / this->timer_wheel_.resolution_) - % this->timer_wheel_.wheel_size_; - this->time_ = ACE_Time_Value (et.sec (), - this->pos_ * this->timer_wheel_.resolution_); - } + this->pos_ = (et.usec () / this->timer_wheel_.resolution_) + % this->timer_wheel_.wheel_size_; + this->time_ = ACE_Time_Value (et.sec (), + this->pos_ * this->timer_wheel_.resolution_); + } // Remove the earliest item @@ -38,8 +38,8 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR>::next (ACE_Timer_Node_T<TYPE, FUNCTOR> return 1; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR>::reset (void) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, LOCK>::reset (void) { ACE_Time_Value et = this->timer_wheel_.earliest_time (); @@ -51,11 +51,11 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR>::reset (void) ACE_ALLOC_HOOK_DEFINE(ACE_Timer_Wheel_T) -template <class TYPE, class FUNCTOR> -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::ACE_Timer_Wheel_T (size_t wheelsize, - size_t resolution, - size_t prealloc, - FUNCTOR *upcall_functor) + template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::ACE_Timer_Wheel_T (size_t wheelsize, + size_t resolution, + size_t prealloc, + FUNCTOR *upcall_functor) : INHERITED (upcall_functor), wheel_size_ (wheelsize), resolution_ (resolution), @@ -69,60 +69,60 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::ACE_Timer_Wheel_T (size_t wheelsize, size_t i; // Create the timing wheel - ACE_NEW (this->wheel_, (ACE_Timer_Node_T<TYPE, FUNCTOR> *[wheelsize])); + ACE_NEW (this->wheel_, (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *[wheelsize])); for (i = 0; i < wheelsize; i++) - { - // Create the dummy nodes - ACE_Timer_Node_T<TYPE, FUNCTOR> *tempnode = this->alloc_node (); - tempnode->next_ = tempnode->prev_ = tempnode; - this->wheel_[i] = tempnode; - } + { + // Create the dummy nodes + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *tempnode = this->alloc_node (); + tempnode->next_ = tempnode->prev_ = tempnode; + this->wheel_[i] = tempnode; + } // Do the preallocation for (i = 0; i < prealloc; i++) - { - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp; - ACE_NEW (temp, (ACE_Timer_Node_T<TYPE, FUNCTOR>)); - temp->next_ = this->freelist_; - this->freelist_ = temp; - } + { + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp; + ACE_NEW (temp, (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>)); + temp->next_ = this->freelist_; + this->freelist_ = temp; + } } -template <class TYPE, class FUNCTOR> -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::~ACE_Timer_Wheel_T (void) +template <class TYPE, class FUNCTOR, class LOCK> +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::~ACE_Timer_Wheel_T (void) { ACE_TRACE ("ACE_Timer_Wheel_T::~ACE_Timer_Wheel_T"); for (size_t i = 0; i < this->wheel_size_; i++) - { - // delete nodes until only the dummy node is left - while (this->wheel_[i]->next_ != this->wheel_[i]) { - ACE_Timer_Node_T<TYPE, FUNCTOR> *next = this->wheel_[i]->next_; - this->wheel_[i]->next_ = next->next_; - next->next_->prev_ = this->wheel_[i]; - this->free_node (next); + // delete nodes until only the dummy node is left + while (this->wheel_[i]->next_ != this->wheel_[i]) + { + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *next = this->wheel_[i]->next_; + this->wheel_[i]->next_ = next->next_; + next->next_->prev_ = this->wheel_[i]; + this->free_node (next); + } + + // and now delete the dummy node + delete this->wheel_[i]; } - // and now delete the dummy node - delete this->wheel_[i]; - } - // Get rid of the freelist now while (this->freelist_ != NULL) - { - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->freelist_; - this->freelist_ = temp->next_; - delete temp; - } + { + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->freelist_; + this->freelist_ = temp->next_; + delete temp; + } delete [] this->wheel_; } -template <class TYPE, class FUNCTOR> int -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::is_empty (void) const +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::is_empty (void) const { ACE_TRACE ("ACE_Timer_Wheel_T::is_empty"); @@ -130,8 +130,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::is_empty (void) const return this->size_ == 0; } -template <class TYPE, class FUNCTOR> const ACE_Time_Value & -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::earliest_time (void) const +template <class TYPE, class FUNCTOR, class LOCK> const ACE_Time_Value & +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::earliest_time (void) const { ACE_TRACE ("ACE_Timer_Wheel_T::earliest_time"); @@ -140,47 +140,47 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::earliest_time (void) const // Check every entry in the table for (size_t i = 0; i < this->wheel_size_; i++) - { - // Check for an empty entry - if (this->wheel_[i]->next_ != this->wheel_[i]) { - // if initialization or if the time is earlier - if (earliest_time == ACE_Time_Value::zero - || this->wheel_[i]->timer_value_ < earliest_time) - { - earliest_time = this->wheel_[i]->next_->timer_value_; - earliest_pos = i; - } + // Check for an empty entry + if (this->wheel_[i]->next_ != this->wheel_[i]) + { + // if initialization or if the time is earlier + if (earliest_time == ACE_Time_Value::zero + || this->wheel_[i]->timer_value_ < earliest_time) + { + earliest_time = this->wheel_[i]->next_->timer_value_; + earliest_pos = i; + } + } } - } return this->wheel_[earliest_pos]->next_->timer_value_; } -template <class TYPE, class FUNCTOR> long -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::schedule (const TYPE &type, - const void *act, - const ACE_Time_Value &delay, - const ACE_Time_Value &interval) +template <class TYPE, class FUNCTOR, class LOCK> long +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::schedule (const TYPE &type, + const void *act, + const ACE_Time_Value &delay, + const ACE_Time_Value &interval) { ACE_TRACE ("ACE_Timer_Wheel_T::schedule"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); - ACE_Timer_Node_T<TYPE, FUNCTOR> *tempnode = this->alloc_node (); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *tempnode = this->alloc_node (); if (tempnode) { // Note that the timer_id is actually the pointer to the node // Use operator placement new. - new (tempnode) ACE_Timer_Node_T<TYPE, FUNCTOR> (type, - act, - delay, - interval, - NULL, - NULL, - (long) tempnode); + new (tempnode) ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> (type, + act, + delay, + interval, + NULL, + NULL, + (long) tempnode); this->reschedule (tempnode); return tempnode->timer_id_; @@ -191,86 +191,82 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::schedule (const TYPE &type, return -1; } -template <class TYPE, class FUNCTOR> int -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::cancel (const TYPE &type, - int dont_call_handle_close) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::cancel (const TYPE &type, + int dont_call_handle_close) { ACE_TRACE ("ACE_Timer_Wheel_T::cancel"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); int number_of_cancellations = 0; for (size_t i = 0; i < this->wheel_size_; i++) - { - ACE_Timer_Node_T<TYPE, FUNCTOR> *curr = this->wheel_[i]->next_; - - while (curr != this->wheel_[i]) { - if (curr->type_ == type) - { - number_of_cancellations++; - - if (dont_call_handle_close == 0 - && number_of_cancellations == 1) - // This calls the correct operator () on the functor (the one with - // two args) - this->upcall_functor_.operator () (*this, curr->type_); - - ACE_Timer_Node_T<TYPE, FUNCTOR> *tempnode = curr; - curr->prev_->next_ = curr->next_; - curr->next_->prev_ = curr->prev_; - curr = curr->next_; - - this->free_node (tempnode); - } - else - { - curr = curr->next_; - } + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *curr = this->wheel_[i]->next_; + + while (curr != this->wheel_[i]) + { + if (curr->type_ == type) + { + number_of_cancellations++; + + if (dont_call_handle_close == 0 + && number_of_cancellations == 1) + this->upcall_functor_.cancellation (*this, curr->type_); + + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *tempnode = curr; + curr->prev_->next_ = curr->next_; + curr->next_->prev_ = curr->prev_; + curr = curr->next_; + + this->free_node (tempnode); + } + else + { + curr = curr->next_; + } + } } - } this->size_ -= number_of_cancellations; return number_of_cancellations; } -template <class TYPE, class FUNCTOR> int -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::cancel (long timer_id, - const void **act, - int dont_call_handle_close) +template <class TYPE, class FUNCTOR, class LOCK> int +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::cancel (long timer_id, + const void **act, + int dont_call_handle_close) { ACE_TRACE ("ACE_Timer_Wheel_T::cancel"); - ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1)); + ACE_MT (ACE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1)); - ACE_Timer_Node_T<TYPE, FUNCTOR> *node = (ACE_Timer_Node_T<TYPE, FUNCTOR> *) timer_id; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *node = (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *) timer_id; ACE_ASSERT (timer_id == node->timer_id_); - // Check to see if the node looks like a true ACE_Timer_Node_T<TYPE, FUNCTOR> + // Check to see if the node looks like a true ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> if (timer_id == node->timer_id_) - { - node->next_->prev_ = node->prev_; - node->prev_->next_ = node->next_; + { + node->next_->prev_ = node->prev_; + node->prev_->next_ = node->next_; - if (act != 0) - *act = node->act_; + if (act != 0) + *act = node->act_; - if (dont_call_handle_close == 0) - // This calls the correct operator () on the functor (the one with - // two args) - this->upcall_functor_.operator () (*this, node->type_); + if (dont_call_handle_close == 0) + this->upcall_functor_.cancellation (*this, node->type_); - this->free_node (node); - this->size_--; - return 1; - } + this->free_node (node); + this->size_--; + return 1; + } // Didn't find it if we are here return 0; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::dump (void) const +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::dump (void) const { ACE_TRACE ("ACE_Timer_Wheel_T::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); @@ -282,41 +278,41 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::dump (void) const ACE_DEBUG ((LM_DEBUG, "\nwheel_ = \n")); for (size_t i = 0; i < this->wheel_size_; i++) - { - ACE_DEBUG ((LM_DEBUG, "%d\n", i)); - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->wheel_[i]->next_; - while (temp != this->wheel_[i]) { - temp->dump (); - temp = temp->next_; + ACE_DEBUG ((LM_DEBUG, "%d\n", i)); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->wheel_[i]->next_; + while (temp != this->wheel_[i]) + { + temp->dump (); + temp = temp->next_; + } } - } ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -template <class TYPE, class FUNCTOR> ACE_Timer_Node_T<TYPE, FUNCTOR> * -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::alloc_node (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> * +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::alloc_node (void) { - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp; if (this->freelist_ == NULL) - { - ACE_NEW_RETURN (temp, - (ACE_Timer_Node_T<TYPE, FUNCTOR>), - 0); - } + { + ACE_NEW_RETURN (temp, + (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>), + 0); + } else - { - temp = this->freelist_; - this->freelist_ = temp->next_; - } + { + temp = this->freelist_; + this->freelist_ = temp->next_; + } return temp; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *node) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *node) { // Add to the beginning of the freelist node->next_ = this->freelist_; @@ -327,8 +323,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *no node->timer_id_ = 0; } -template <class TYPE, class FUNCTOR> ACE_Timer_Node_T<TYPE, FUNCTOR> * -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::remove (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> * +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::remove (void) { ACE_TRACE ("ACE_Timer_Wheel_T::remove"); @@ -337,22 +333,22 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::remove (void) // Check every entry in the table for (size_t i = 0; i < this->wheel_size_; i++) - { - // Check for an empty entry - if (this->wheel_[i]->next_ != this->wheel_[i]) { - // if initialization or if the time is earlier - if (earliest_time == ACE_Time_Value::zero - || this->wheel_[i]->timer_value_ < earliest_time) - { - earliest_time = this->wheel_[i]->next_->timer_value_; - earliest_pos = i; - } + // Check for an empty entry + if (this->wheel_[i]->next_ != this->wheel_[i]) + { + // if initialization or if the time is earlier + if (earliest_time == ACE_Time_Value::zero + || this->wheel_[i]->timer_value_ < earliest_time) + { + earliest_time = this->wheel_[i]->next_->timer_value_; + earliest_pos = i; + } + } } - } // Remove and return - ACE_Timer_Node_T<TYPE, FUNCTOR> *temp = this->wheel_[earliest_pos]->next_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *temp = this->wheel_[earliest_pos]->next_; temp->prev_->next_ = temp->next_; temp->next_->prev_ = temp->prev_; @@ -361,8 +357,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::remove (void) return temp; } -template <class TYPE, class FUNCTOR> void -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *expired) +template <class TYPE, class FUNCTOR, class LOCK> void +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *expired) { ACE_TRACE ("ACE_Timer_Wheel_T::reschedule"); @@ -370,7 +366,7 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *e // Insert time into dummy node this->wheel_[pos]->timer_value_ = expired->timer_value_; - ACE_Timer_Node_T<TYPE, FUNCTOR> *cursor = this->wheel_[pos]->next_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *cursor = this->wheel_[pos]->next_; // Find position to insert while (cursor->timer_value_ < expired->timer_value_) @@ -385,8 +381,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR>::reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *e this->size_++; } -template <class TYPE, class FUNCTOR> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> & -ACE_Timer_Wheel_T<TYPE, FUNCTOR>::iter (void) +template <class TYPE, class FUNCTOR, class LOCK> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> & +ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK>::iter (void) { this->iterator_.reset (); return this->iterator_; diff --git a/ace/Timer_Wheel_T.h b/ace/Timer_Wheel_T.h index fb68dcd1840..28a2a089d3b 100644 --- a/ace/Timer_Wheel_T.h +++ b/ace/Timer_Wheel_T.h @@ -19,11 +19,11 @@ #include "ace/Timer_Queue.h" // Forward declaration -template <class TYPE, class FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> class ACE_Timer_Wheel_T; -template <class TYPE, class FUNCTOR> -class ACE_Timer_Wheel_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> +class ACE_Timer_Wheel_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR, LOCK> // = TITLE // Iterates over an <ACE_Timer_Wheel>. // @@ -32,10 +32,10 @@ class ACE_Timer_Wheel_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNC // the head of the timer queue up by one every time. { public: - ACE_Timer_Wheel_Iterator_T (ACE_Timer_Wheel_T<TYPE, FUNCTOR> &); + ACE_Timer_Wheel_Iterator_T (ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK> &); // Constructor. - virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR> *&timer_node, + virtual int next (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *&timer_node, const ACE_Time_Value &cur_time); // Pass back the next <timer_node> that hasn't been seen yet, if its // <time_value_> <= <cur_time>. In addition, moves the timer queue @@ -46,7 +46,7 @@ public: // Resets the iterator protected: - ACE_Timer_Wheel_T<TYPE, FUNCTOR> &timer_wheel_; + ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK> &timer_wheel_; // Pointer to the <ACE_Timer_List> that we are iterating over. private: @@ -54,8 +54,8 @@ private: ACE_Time_Value time_; // Corresponding time of <pos_> }; -template <class TYPE, class FUNCTOR> -class ACE_Timer_Wheel_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR> +template <class TYPE, class FUNCTOR, class LOCK> +class ACE_Timer_Wheel_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> // = TITLE // Provides a Timing Wheel version of Timer Queue // @@ -72,13 +72,13 @@ class ACE_Timer_Wheel_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR> // { public: - typedef ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR> WHEEL_ITERATOR; + typedef ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, LOCK> WHEEL_ITERATOR; // Type of iterator - friend class ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR>; + friend class ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, LOCK>; // Iterator is a friend. - typedef ACE_Timer_Queue_T<TYPE, FUNCTOR> INHERITED; + typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, LOCK> INHERITED; // Type inherited from. // = Initialization and termination methods. @@ -137,24 +137,24 @@ public: // Dump the state of an object. protected: - virtual ACE_Timer_Node_T<TYPE, FUNCTOR> *alloc_node (void); + virtual ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *alloc_node (void); // Factory method that allocates a new node (uses operator new). - virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR> *); + virtual void free_node (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *); // Factory method that frees a previously allocated node (uses // operator delete). private: - ACE_Timer_Node_T<TYPE, FUNCTOR> *remove (void); + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *remove (void); // Removes the earliest node and returns a pointer to it. - virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR> *); + virtual void reschedule (ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *); // Reschedule an "interval" node - virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR> &iter (void); + virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, LOCK> &iter (void); // Returns a pointer to this <ACE_Timer_Queue_T>'s iterator. - ACE_Timer_Node_T<TYPE, FUNCTOR> **wheel_; + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> **wheel_; // Timing Wheel. size_t wheel_size_; @@ -172,15 +172,15 @@ private: long size_; // Keeps track of the size of the queue - ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR> iterator_; + ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, LOCK> iterator_; // Iterator used to expire timers. - ACE_Timer_Node_T<TYPE, FUNCTOR> *freelist_; - // Pointer to the freelist of <ACE_Timer_Node_T<TYPE, FUNCTOR>>. + ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK> *freelist_; + // Pointer to the freelist of <ACE_Timer_Node_T<TYPE, FUNCTOR, LOCK>>. // = Don't allow these operations for now. - ACE_Timer_Wheel_T (const ACE_Timer_Wheel_T<TYPE, FUNCTOR> &); - void operator= (const ACE_Timer_Wheel_T<TYPE, FUNCTOR> &); + ACE_Timer_Wheel_T (const ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK> &); + void operator= (const ACE_Timer_Wheel_T<TYPE, FUNCTOR, LOCK> &); }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) |