summaryrefslogtreecommitdiff
path: root/ACE/ace/Timer_Heap_T.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/Timer_Heap_T.cpp')
-rw-r--r--ACE/ace/Timer_Heap_T.cpp140
1 files changed, 73 insertions, 67 deletions
diff --git a/ACE/ace/Timer_Heap_T.cpp b/ACE/ace/Timer_Heap_T.cpp
index c15597cf334..607e8e9348e 100644
--- a/ACE/ace/Timer_Heap_T.cpp
+++ b/ACE/ace/Timer_Heap_T.cpp
@@ -39,34 +39,34 @@ ACE_HEAP_LCHILD (size_t X)
// Constructor that takes in an <ACE_Timer_Heap_T> to iterate over.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_Iterator_T (
- ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK> &heap)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Heap_Iterator_T (
+ Heap & heap)
: timer_heap_ (heap)
{
ACE_TRACE ("ACE_Timer_Heap_Iterator_T::ACE_Timer_Heap_Iterator");
this->first ();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Heap_Iterator_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::~ACE_Timer_Heap_Iterator_T (void)
{
}
// Positions the iterator at the first node in the heap array
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void)
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::first (void)
{
this->position_ = 0;
}
// Positions the iterator at the next node in the heap array
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::next (void)
{
if (this->position_ != this->timer_heap_.cur_size_)
++this->position_;
@@ -74,16 +74,16 @@ ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
// Returns true the <position_> is at the end of the heap array
-template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
-ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> bool
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::isdone (void) const
{
return this->position_ == this->timer_heap_.cur_size_;
}
// Returns the node at the current position in the heap or 0 if at the end
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::item (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::item (void)
{
if (this->position_ != this->timer_heap_.cur_size_)
return this->timer_heap_.heap_[this->position_];
@@ -95,13 +95,16 @@ ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::item (void)
// Since timer IDs are assigned by first incrementing the timer_ids_curr_
// value, the first ID assigned will be 1 (just as in the previous design).
// When it's time to wrap, the next ID given out will be 0.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Heap_T (
size_t size,
bool preallocated,
FUNCTOR *upcall_functor,
- ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
- : ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK> (upcall_functor, freelist),
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist,
+ TIME_POLICY const & time_policy)
+ : ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK> (upcall_functor,
+ freelist,
+ time_policy),
max_size_ (size),
cur_size_ (0),
cur_limbo_ (0),
@@ -162,11 +165,14 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (
// Since timer IDs are assigned by first incrementing the timer_ids_curr_
// value, the first ID assigned will be 1 (just as in the previous design).
// When it's time to wrap, the next ID given out will be 0.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Heap_T (
FUNCTOR *upcall_functor,
- ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
- : ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK> (upcall_functor, freelist),
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist,
+ TIME_POLICY const & time_policy)
+ : ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK> (upcall_functor,
+ freelist,
+ time_policy),
max_size_ (ACE_DEFAULT_TIMERS),
cur_size_ (0),
cur_limbo_ (0),
@@ -199,8 +205,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Heap_T (
HEAP_ITERATOR (*this));
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Heap_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::~ACE_Timer_Heap_T (void)
{
ACE_TRACE ("ACE_Timer_Heap_T::~ACE_Timer_Heap_T");
@@ -238,9 +244,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Heap_T (void)
}
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
long
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::pop_freelist (void)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::pop_freelist (void)
{
ACE_TRACE ("ACE_Timer_Heap_T::pop_freelist");
@@ -271,9 +277,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::pop_freelist (void)
return static_cast<long> (this->timer_ids_curr_);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::push_freelist (long old_id)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::push_freelist (long old_id)
{
ACE_TRACE ("ACE_Timer_Heap_T::push_freelist");
@@ -296,9 +302,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::push_freelist (long old_id)
return;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
long
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::timer_id (void)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::timer_id (void)
{
ACE_TRACE ("ACE_Timer_Heap_T::timer_id");
@@ -308,17 +314,17 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::timer_id (void)
// Checks if queue is empty.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
bool
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::is_empty (void) const
{
ACE_TRACE ("ACE_Timer_Heap_T::is_empty");
return this->cur_size_ == 0;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::iter (void)
{
this->iterator_->first ();
return *this->iterator_;
@@ -326,16 +332,16 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
// Returns earliest time in a non-empty queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> const ACE_Time_Value &
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> const ACE_Time_Value &
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::earliest_time (void) const
{
ACE_TRACE ("ACE_Timer_Heap_T::earliest_time");
return this->heap_[0]->get_timer_value ();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Timer_Heap_T::dump");
@@ -371,9 +377,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
#endif /* ACE_HAS_DUMP */
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::copy (
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::copy (
size_t slot,
ACE_Timer_Node_T<TYPE> *moved_node)
{
@@ -392,9 +398,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::copy (
// this function must call either free_node (to reclaim the timer ID
// and the timer node memory, as well as decrement the size of the queue)
// or reschedule (to reinsert the node in the heap at a new time).
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::remove (size_t slot)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::remove (size_t slot)
{
ACE_Timer_Node_T<TYPE> *removed_node =
this->heap_[slot];
@@ -437,8 +443,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::remove (size_t slot)
return removed_node;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_down (
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reheap_down (
ACE_Timer_Node_T<TYPE> *moved_node,
size_t slot,
size_t child)
@@ -471,9 +477,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_down (
this->copy (slot, moved_node);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_up (
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reheap_up (
ACE_Timer_Node_T<TYPE> *moved_node,
size_t slot,
size_t parent)
@@ -501,9 +507,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_up (
moved_node);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::insert (
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::insert (
ACE_Timer_Node_T<TYPE> *new_node)
{
if (this->cur_size_ + this->cur_limbo_ + 2 >= this->max_size_)
@@ -515,9 +521,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::insert (
this->cur_size_++;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::grow_heap (void)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::grow_heap (void)
{
// All the containers will double in size from max_size_.
size_t new_size = this->max_size_ * 2;
@@ -611,9 +617,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::grow_heap (void)
// Reschedule a periodic timer. This function must be called with the
// mutex lock held.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reschedule (
ACE_Timer_Node_T<TYPE> *expired)
{
ACE_TRACE ("ACE_Timer_Heap_T::reschedule");
@@ -628,9 +634,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (
this->insert (expired);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::alloc_node (void)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::alloc_node (void)
{
ACE_Timer_Node_T<TYPE> *temp = 0;
@@ -654,9 +660,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::alloc_node (void)
return temp;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::free_node (
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::free_node (
ACE_Timer_Node_T<TYPE> *node)
{
// Return this timer id to the freelist.
@@ -675,9 +681,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::free_node (
// Insert a new timer that expires at time future_time; if interval is
// > 0, the handler will be reinvoked periodically.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
long
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::schedule_i (
const TYPE &type,
const void *act,
const ACE_Time_Value &future_time,
@@ -713,9 +719,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (
// Locate and remove the single timer with a value of @a timer_id from
// the timer queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
int
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel (long timer_id,
const void **act,
int dont_call)
{
@@ -770,9 +776,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
// Locate and update the inteval on the timer_id
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
int
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reset_interval (long timer_id,
const ACE_Time_Value &interval)
{
ACE_TRACE ("ACE_Timer_Heap_T::reset_interval");
@@ -806,9 +812,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
// Locate and remove all values of @a type from the timer queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
int
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type,
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel (const TYPE &type,
int dont_call)
{
ACE_TRACE ("ACE_Timer_Heap_T::cancel");
@@ -863,9 +869,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type,
// Returns the earliest node or returns 0 if the heap is empty.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
ACE_Timer_Node_T <TYPE> *
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::remove_first (void)
{
ACE_TRACE ("ACE_Timer_Heap_T::remove_first");
@@ -875,9 +881,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
return this->remove (0);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
ACE_Timer_Node_T <TYPE> *
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::get_first (void)
{
ACE_TRACE ("ACE_Timer_Heap_T::get_first");