summaryrefslogtreecommitdiff
path: root/ACE/ace/Timer_Hash_T.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/Timer_Hash_T.cpp')
-rw-r--r--ACE/ace/Timer_Hash_T.cpp140
1 files changed, 70 insertions, 70 deletions
diff --git a/ACE/ace/Timer_Hash_T.cpp b/ACE/ace/Timer_Hash_T.cpp
index c3e452301f0..44f658979d5 100644
--- a/ACE/ace/Timer_Hash_T.cpp
+++ b/ACE/ace/Timer_Hash_T.cpp
@@ -171,18 +171,24 @@ ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::deletion (
return result;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
-ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_Iterator_T (ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &hash)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::ACE_Timer_Hash_Iterator_T (Hash & hash)
: timer_hash_ (hash)
{
this->first ();
// Nothing
}
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::~ACE_Timer_Hash_Iterator_T ()
+{
+ // Nothing
+}
+
// Positions the iterator at the first node in the timing hash table
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
-ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> void
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::first (void)
{
for (this->position_ = 0;
this->position_ < this->timer_hash_.table_size_;
@@ -204,8 +210,8 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::first (void)
// Positions the iterator at the next node in the bucket or goes to the next
// bucket
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
-ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::next (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> void
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::next (void)
{
if (this->isdone ())
return;
@@ -235,17 +241,17 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::next (void)
// Returns true when we are at the end (when bucket_item_ == 0)
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> bool
-ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::isdone (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> bool
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::isdone (void) const
{
return this->iter_ == 0;
}
// Returns the node at the current position in the sequence
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::item (void)
+ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::item (void)
{
if (this->isdone ())
return 0;
@@ -253,9 +259,9 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::item (void)
return this->iter_->item ();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
-ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::iter (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
+ACE_Timer_Queue_Iterator_T<TYPE> &
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::iter (void)
{
this->iterator_->first ();
return *this->iterator_;
@@ -263,12 +269,13 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::iter (void)
// Create an empty queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::ACE_Timer_Hash_T (
size_t table_size,
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)
+ : Base_Timer_Queue (upcall_functor, freelist, time_policy),
size_ (0),
table_size_ (table_size),
table_functor_ (this),
@@ -283,16 +290,14 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
ACE_NEW (table_,
BUCKET *[table_size]);
- this->gettimeofday (ACE_OS::gettimeofday);
-
for (size_t i = 0;
i < table_size;
++i)
{
ACE_NEW (this->table_[i],
BUCKET (&this->table_functor_,
- this->free_list_));
- this->table_[i]->gettimeofday (ACE_OS::gettimeofday);
+ this->free_list_,
+ time_policy));
}
ACE_NEW (iterator_,
@@ -300,11 +305,12 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::ACE_Timer_Hash_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)
+ : Base_Timer_Queue (upcall_functor, freelist, time_policy),
size_ (0),
table_size_ (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE),
table_functor_ (this),
@@ -319,17 +325,14 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
ACE_NEW (table_,
BUCKET *[ACE_DEFAULT_TIMER_HASH_TABLE_SIZE]);
-
- this->gettimeofday (ACE_OS::gettimeofday);
-
for (size_t i = 0;
i < this->table_size_;
++i)
{
ACE_NEW (this->table_[i],
BUCKET (&this->table_functor_,
- this->free_list_));
- this->table_[i]->gettimeofday (ACE_OS::gettimeofday);
+ this->free_list_,
+ time_policy));
}
ACE_NEW (iterator_,
@@ -338,8 +341,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
// Remove all remaining items in the Queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::~ACE_Timer_Hash_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::~ACE_Timer_Hash_T (void)
{
ACE_TRACE ("ACE_Timer_Hash_T::~ACE_Timer_Hash_T");
ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
@@ -356,8 +359,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::~ACE_Timer_Hash_T (void)
// Checks if queue is empty.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> bool
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::is_empty (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> bool
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::is_empty (void) const
{
ACE_TRACE ("ACE_Timer_Hash_T::is_empty");
return this->table_[this->earliest_position_]->is_empty ();
@@ -365,16 +368,16 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::is_empty (void) const
// Returns earliest time in a non-empty bucket
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
const ACE_Time_Value &
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::earliest_time (void) const
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::earliest_time (void) const
{
ACE_TRACE ("ACE_Timer_Hash_T::earliest_time");
return this->table_[this->earliest_position_]->earliest_time ();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dump (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> void
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Timer_Hash_T::dump");
@@ -394,9 +397,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dump (void) const
// Reschedule a periodic timer. This function must be called with the
// mutex lock held.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
void
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule (
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::reschedule (
ACE_Timer_Node_T<TYPE> *expired)
{
ACE_TRACE ("ACE_Timer_Hash_T::reschedule");
@@ -423,7 +426,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule (
// then here schedule <expired> for deletion. Don't call
// this->free_node() because that will invalidate <h>
// and that's what user have as timer_id.
- ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::free_node (expired);
+ Base_Timer_Queue::free_node (expired);
if (this->table_[this->earliest_position_]->is_empty ()
|| this->table_[h->pos_]->earliest_time ()
@@ -434,9 +437,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule (
// Insert a new handler that expires at time future_time; if interval
// is > 0, the handler will be reinvoked periodically.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
long
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule_i (
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::schedule_i (
const TYPE &type,
const void *act,
const ACE_Time_Value &future_time,
@@ -489,9 +492,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule_i (
// Locate and update the inteval on the timer_id
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
int
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reset_interval (
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::reset_interval (
long timer_id,
const ACE_Time_Value & interval)
{
@@ -526,9 +529,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reset_interval (
// Locate and remove the single <ACE_Event_Handler> with a value of
// @a timer_id from the correct table timer queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
int
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (long timer_id,
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::cancel (long timer_id,
const void **act,
int dont_call)
{
@@ -596,9 +599,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (long timer_id,
// Locate and remove all values of <type> from the timer queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
int
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type,
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::cancel (const TYPE &type,
int dont_call)
{
ACE_TRACE ("ACE_Timer_Hash_T::cancel");
@@ -618,9 +621,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type,
i < this->table_size_;
++i)
{
- ACE_Timer_Queue_Iterator_T<TYPE,
- ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>,
- ACE_Null_Mutex> &iter =
+ ACE_Timer_Queue_Iterator_T<TYPE> & iter =
this->table_[i]->iter ();
for (iter.first ();
@@ -680,8 +681,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type,
// Removes the earliest node and finds the new earliest position
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::remove_first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::remove_first (void)
{
if (this->is_empty ())
return 0;
@@ -698,8 +699,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::remove_first (void)
// Finds a new earliest position
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::find_new_earliest (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> void
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::find_new_earliest (void)
{
for (size_t i = 0; i < this->table_size_; ++i)
if (!this->table_[i]->is_empty ())
@@ -711,8 +712,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::find_new_earliest (void)
// Returns the earliest node without removing it
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::get_first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::get_first (void)
{
ACE_TRACE ("ACE_Timer_Hash_T::get_first");
@@ -722,23 +723,22 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::get_first (void)
return this->table_[this->earliest_position_]->get_first ();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> void
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::free_node (ACE_Timer_Node_T<TYPE> *node)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> void
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::free_node (ACE_Timer_Node_T<TYPE> *node)
{
- ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::free_node (node);
+ Base_Timer_Queue::free_node (node);
Hash_Token<TYPE> *h =
reinterpret_cast<Hash_Token<TYPE> *> (const_cast<void *> (node->get_act ()));
this->token_list_.add (h);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dispatch_info_i (const ACE_Time_Value &cur_time,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::dispatch_info_i (const ACE_Time_Value &cur_time,
ACE_Timer_Node_Dispatch_Info_T<TYPE> &info)
{
int const result =
- ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::dispatch_info_i (cur_time,
- info);
+ Base_Timer_Queue::dispatch_info_i (cur_time, info);
if (result == 1)
{
@@ -753,16 +753,16 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dispatch_info_i (const ACE_Ti
// Dummy version of expire to get rid of warnings in Sun CC 4.2
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire ()
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::expire ()
{
- return ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::expire();
+ return Base_Timer_Queue::expire();
}
// Specialized expire for Timer Hash
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET> int
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire (const ACE_Time_Value &cur_time)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY> int
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::expire (const ACE_Time_Value &cur_time)
{
ACE_TRACE ("ACE_Timer_Hash_T::expire");