summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-06-30 01:17:41 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-06-30 01:17:41 +0000
commitaa1eef1fa01b1db730140bf91cb9439594ce49de (patch)
tree2b128a52c07666223d6db4702a0495507f92be4c
parent3b9af40d469cb7e94989a36e7dc83cc6f7d531a7 (diff)
downloadATCD-aa1eef1fa01b1db730140bf91cb9439594ce49de.tar.gz
Tue Jun 30 01:10:04 UTC 2009 Carlos O'Ryan <coryan@glamdring>
* This is a temporary commit into the 3707 branch. I realized too late that the changes from 3706 will be needed to make this work. * ace/ace.mpc: * ace/Time_Policy.h: * ace/Time_Policy.inl: * ace/Time_Policy.cpp: New classes to encapsulate how "now" is computed in the Timer Queues. This will be an additional template parameter, so the default configuration has zero overhead. * ace/Timer_Queuefwd.h: * ace/Timer_List.h: * ace/Timer_List_T.h: * ace/Timer_List_T.cpp: * ace/Timer_Queue_T.h: * ace/Timer_Queue_T.inl: * ace/Timer_Queue_T.cpp: * ace/Timer_Wheel.h: * ace/Timer_Wheel_T.h: * ace/Timer_Wheel_T.cpp: * ace/Timer_Hash.h: * ace/Timer_Hash_T.h: * ace/Timer_Hash_T.cpp: * ace/Timer_Heap.h: * ace/Timer_Heap_T.h: * ace/Timer_Heap_T.cpp: Re-factor timer queue classes to use new TIMER_POLICY parameter. * tests/Timer_Queue_Test.cpp: Modify test to use TIMER_POLICY. But here is the rub, the test does not compile because all timer queue types are "different" to each other. I need to introduce the base class from the bug-3706 branch to make things work.
-rw-r--r--ACE/ChangeLog38
-rw-r--r--ACE/ace/Time_Policy.cpp12
-rw-r--r--ACE/ace/Time_Policy.h90
-rw-r--r--ACE/ace/Time_Policy.inl34
-rw-r--r--ACE/ace/Timer_Hash.h3
-rw-r--r--ACE/ace/Timer_Hash_T.cpp100
-rw-r--r--ACE/ace/Timer_Hash_T.h28
-rw-r--r--ACE/ace/Timer_Heap.h3
-rw-r--r--ACE/ace/Timer_Heap_T.cpp140
-rw-r--r--ACE/ace/Timer_Heap_T.h29
-rw-r--r--ACE/ace/Timer_List.h3
-rw-r--r--ACE/ace/Timer_List_T.cpp96
-rw-r--r--ACE/ace/Timer_List_T.h18
-rw-r--r--ACE/ace/Timer_Queue_T.cpp53
-rw-r--r--ACE/ace/Timer_Queue_T.h20
-rw-r--r--ACE/ace/Timer_Queue_T.inl44
-rw-r--r--ACE/ace/Timer_Queuefwd.h6
-rw-r--r--ACE/ace/Timer_Wheel.h3
-rw-r--r--ACE/ace/Timer_Wheel_T.cpp152
-rw-r--r--ACE/ace/Timer_Wheel_T.h29
-rw-r--r--ACE/ace/ace.mpc1
-rw-r--r--ACE/tests/Timer_Queue_Test.cpp11
22 files changed, 550 insertions, 363 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 78965f2f08f..6c915c76e95 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,41 @@
+Tue Jun 30 01:10:04 UTC 2009 Carlos O'Ryan <coryan@glamdring>
+
+ * This is a temporary commit into the 3707 branch. I realized too
+ late that the changes from 3706 will be needed to make this work.
+
+ * ace/ace.mpc:
+ * ace/Time_Policy.h:
+ * ace/Time_Policy.inl:
+ * ace/Time_Policy.cpp:
+ New classes to encapsulate how "now" is computed in the Timer
+ Queues. This will be an additional template parameter, so the
+ default configuration has zero overhead.
+
+ * ace/Timer_Queuefwd.h:
+ * ace/Timer_List.h:
+ * ace/Timer_List_T.h:
+ * ace/Timer_List_T.cpp:
+ * ace/Timer_Queue_T.h:
+ * ace/Timer_Queue_T.inl:
+ * ace/Timer_Queue_T.cpp:
+ * ace/Timer_Wheel.h:
+ * ace/Timer_Wheel_T.h:
+ * ace/Timer_Wheel_T.cpp:
+ * ace/Timer_Hash.h:
+ * ace/Timer_Hash_T.h:
+ * ace/Timer_Hash_T.cpp:
+ * ace/Timer_Heap.h:
+ * ace/Timer_Heap_T.h:
+ * ace/Timer_Heap_T.cpp:
+ Re-factor timer queue classes to use new TIMER_POLICY
+ parameter.
+
+ * tests/Timer_Queue_Test.cpp:
+ Modify test to use TIMER_POLICY. But here is the rub, the test
+ does not compile because all timer queue types are "different"
+ to each other. I need to introduce the base class from the
+ bug-3706 branch to make things work.
+
Sat Jun 27 00:55:10 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl>
* rpmbuild/ace-tao-ciao.spec:
diff --git a/ACE/ace/Time_Policy.cpp b/ACE/ace/Time_Policy.cpp
new file mode 100644
index 00000000000..bb06f79e18e
--- /dev/null
+++ b/ACE/ace/Time_Policy.cpp
@@ -0,0 +1,12 @@
+// $Id$
+
+#include "ace/Time_Policy.h"
+
+#if !defined(__ACE_INLINE__)
+# include "ace/Time_Policy.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
diff --git a/ACE/ace/Time_Policy.h b/ACE/ace/Time_Policy.h
new file mode 100644
index 00000000000..f0149293123
--- /dev/null
+++ b/ACE/ace/Time_Policy.h
@@ -0,0 +1,90 @@
+#ifndef ACE_TIME_POLICY_H
+#define ACE_TIME_POLICY_H
+// -*- C++ -*-
+/**
+ * @file Time_Policy.h
+ *
+ * $Id$
+ *
+ * @author Carlos O'Ryan <coryan@atdesk.com>
+ */
+#include /**/ "ace/pre.h"
+
+#include /**/ "ace/config-all.h"
+
+#include /**/ "ace/Time_Value.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/**
+ * @class ACE_Default_Time_Policy
+ *
+ * @brief Implement the default time policy for ACE.
+ *
+ * The most common time policy is to simply use
+ * ACE_OS::gettimeofday(), this class implements that policy, i.e., it
+ * simply calls that function.
+ */
+class ACE_Export ACE_Default_Time_Policy
+{
+public:
+ /// Return the current time according to this policy
+ ACE_Time_Value operator() () const;
+};
+
+/**
+ * @class ACE_FPointer_Timer_Policy
+ *
+ * @brief Implement a time policy based on a function pointer.
+ *
+ * This time policy allows dynamic changes to the source of time by
+ * using a function pointer.
+ */
+class ACE_Export ACE_FPointer_Time_Policy
+{
+public:
+ /**
+ * @brief Default constructor uses ACE_OS::gettimeofday()
+ *
+ * ACE_T requires a default constructor that leaves the
+ * policy in a functional state. Therefore, a null pointer would
+ * not be desirable, in other words, we need a non-trivial default
+ * constructor.
+ */
+ ACE_FPointer_Time_Policy();
+
+ /**
+ * @typedef FPtr
+ *
+ * Short-hand for the right type of pointer to function.
+ */
+ typedef ACE_Time_Value (*FPtr)();
+
+ /**
+ * @brief Constructor from a pointer to function.
+ *
+ * Construct from a pointer to function.
+ */
+ ACE_FPointer_Time_Policy(FPtr f);
+
+ /// Return the current time according to this policy
+ ACE_Time_Value operator()() const;
+
+
+private:
+ FPtr function_;
+};
+
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/Time_Policy.inl"
+#endif /* __ACE_INLINE__ */
+
+#include /**/ "ace/post.h"
+#endif /* ACE_TIME_POLICY_H */
diff --git a/ACE/ace/Time_Policy.inl b/ACE/ace/Time_Policy.inl
new file mode 100644
index 00000000000..4120c10e400
--- /dev/null
+++ b/ACE/ace/Time_Policy.inl
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "ace/OS_NS_sys_time.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE ACE_Time_Value
+ACE_Default_Time_Policy::operator()() const
+{
+ return ACE_OS::gettimeofday();
+}
+
+ACE_INLINE
+ACE_FPointer_Time_Policy::ACE_FPointer_Time_Policy()
+ : function_(ACE_OS::gettimeofday)
+{
+}
+
+ACE_INLINE
+ACE_FPointer_Time_Policy::
+ACE_FPointer_Time_Policy(ACE_FPointer_Time_Policy::FPtr f)
+ : function_(f)
+{
+}
+
+ACE_INLINE ACE_Time_Value
+ACE_FPointer_Time_Policy::operator()() const
+{
+ return (*this->function_)();
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Timer_Hash.h b/ACE/ace/Timer_Hash.h
index 2d959be39c5..2c41f30af6f 100644
--- a/ACE/ace/Timer_Hash.h
+++ b/ACE/ace/Timer_Hash.h
@@ -54,7 +54,8 @@ typedef ACE_Timer_Hash_T<ACE_Event_Handler *,
typedef ACE_Timer_Hash_Iterator_T<ACE_Event_Handler *,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,
ACE_SYNCH_RECURSIVE_MUTEX,
- ACE_Hash_Timer_List>
+ ACE_Hash_Timer_List,
+ ACE_Default_Time_Policy>
ACE_Timer_Hash_Iterator;
typedef ACE_Timer_Hash_T<ACE_Event_Handler *,
diff --git a/ACE/ace/Timer_Hash_T.cpp b/ACE/ace/Timer_Hash_T.cpp
index a2a81fc3773..ade274ea14a 100644
--- a/ACE/ace/Timer_Hash_T.cpp
+++ b/ACE/ace/Timer_Hash_T.cpp
@@ -175,8 +175,8 @@ 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 ();
@@ -185,8 +185,8 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_Itera
// 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_;
@@ -208,8 +208,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;
@@ -239,17 +239,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;
@@ -257,9 +257,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>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
-ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::iter (void)
+ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>::iter (void)
{
this->iterator_->first ();
return *this->iterator_;
@@ -267,8 +267,8 @@ 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)
@@ -304,8 +304,8 @@ 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),
@@ -323,9 +323,6 @@ 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)
@@ -333,7 +330,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (
ACE_NEW (this->table_[i],
BUCKET (&this->table_functor_,
this->free_list_));
- this->table_[i]->gettimeofday (ACE_OS::gettimeofday);
}
ACE_NEW (iterator_,
@@ -342,8 +338,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_));
@@ -360,8 +356,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 ();
@@ -369,16 +365,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");
@@ -398,9 +394,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");
@@ -446,9 +442,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,
@@ -509,9 +505,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)
{
@@ -546,9 +542,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)
{
@@ -616,9 +612,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");
@@ -700,8 +696,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;
@@ -718,8 +714,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 ())
@@ -731,8 +727,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");
@@ -742,8 +738,8 @@ 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);
@@ -752,8 +748,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::free_node (ACE_Timer_Node_T<T
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 =
@@ -773,16 +769,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();
}
// 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");
diff --git a/ACE/ace/Timer_Hash_T.h b/ACE/ace/Timer_Hash_T.h
index 53072ebd51c..b644c551dfc 100644
--- a/ACE/ace/Timer_Hash_T.h
+++ b/ACE/ace/Timer_Hash_T.h
@@ -25,7 +25,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declaration.
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY>
class ACE_Timer_Hash_T;
template <typename TYPE>
class Hash_Token;
@@ -40,6 +40,7 @@ class Hash_Token;
*/
template <class TYPE, class FUNCTOR, class ACE_LOCK>
class ACE_Timer_Hash_Upcall
+ : private ACE_Copy_Disabled
{
public:
typedef ACE_Timer_Queue_T<ACE_Event_Handler *,
@@ -103,10 +104,6 @@ public:
private:
/// Timer Queue to do the calling up to
ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> *timer_hash_;
-
- // = Don't allow these operations for now.
- ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Hash_Upcall (const ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK> &))
- ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK> &))
};
/**
@@ -118,12 +115,13 @@ private:
* node of a timer queue. Be aware that it doesn't transverse
* in the order of timeout values.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY = ACE_Default_Time_Policy>
class ACE_Timer_Hash_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR, ACE_LOCK>
{
public:
/// Constructor.
- ACE_Timer_Hash_Iterator_T (ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &);
+ typedef ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY> Hash;
+ ACE_Timer_Hash_Iterator_T (Hash &);
/// Positions the iterator at the earliest node in the Timer Queue
virtual void first (void);
@@ -139,7 +137,7 @@ public:
protected:
/// Pointer to the ACE_Timer_Hash that we are iterating over.
- ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &timer_hash_;
+ Hash & timer_hash_;
/// Current position in <timer_hash_>'s table
size_t position_;
@@ -156,21 +154,23 @@ protected:
*
* This implementation uses a hash table of BUCKETs. The hash
* is based on the time_value of the event. Unlike other Timer
- * Queues, ACE_Timer_Hash does not expire events in order.
+ * Queues, ACE_Timer_Hash does not expire events in strict order,
+ * i.e., all events are expired after their deadline. But two events
+ * may expired out of order as defined by their deadlines.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
-class ACE_Timer_Hash_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET, typename TIME_POLICY = ACE_Default_Time_Policy>
+class ACE_Timer_Hash_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
{
public:
/// Type of iterator
- typedef ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>
+ typedef ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>
HASH_ITERATOR;
/// Iterator is a friend
- friend class ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>;
+ friend class ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET, TIME_POLICY>;
/// Type inherited from
- typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> INHERITED;
+ typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> INHERITED;
// = Initialization and termination methods.
/**
diff --git a/ACE/ace/Timer_Heap.h b/ACE/ace/Timer_Heap.h
index a0c9301ebc8..7949fbcfc90 100644
--- a/ACE/ace/Timer_Heap.h
+++ b/ACE/ace/Timer_Heap.h
@@ -32,7 +32,8 @@ typedef ACE_Timer_Heap_T<ACE_Event_Handler *,
typedef ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,
- ACE_SYNCH_RECURSIVE_MUTEX>
+ ACE_SYNCH_RECURSIVE_MUTEX,
+ ACE_Default_Time_Policy>
ACE_Timer_Heap_Iterator;
ACE_END_VERSIONED_NAMESPACE_DECL
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");
diff --git a/ACE/ace/Timer_Heap_T.h b/ACE/ace/Timer_Heap_T.h
index 00c128b1aa9..35766f6acaa 100644
--- a/ACE/ace/Timer_Heap_T.h
+++ b/ACE/ace/Timer_Heap_T.h
@@ -26,7 +26,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declaration
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
class ACE_Timer_Heap_T;
/**
@@ -38,12 +38,13 @@ class ACE_Timer_Heap_T;
* node of a timer queue. Be aware that it doesn't transverse
* in the order of timeout values.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY = ACE_Default_Time_Policy>
class ACE_Timer_Heap_Iterator_T : public ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>
{
public:
+ typedef ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> Heap;
/// Constructor.
- ACE_Timer_Heap_Iterator_T (ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK> &);
+ ACE_Timer_Heap_Iterator_T (Heap &);
/// Destructor.
~ACE_Timer_Heap_Iterator_T (void);
@@ -62,7 +63,7 @@ public:
protected:
/// Pointer to the ACE_Timer_Heap that we are iterating over.
- ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK> &timer_heap_;
+ Heap & timer_heap_;
/// Position in the array where the iterator is at
size_t position_;
@@ -82,14 +83,14 @@ protected:
* dynamic memory allocation, which is important for real-time
* systems.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-class ACE_Timer_Heap_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY = ACE_Default_Time_Policy>
+class ACE_Timer_Heap_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
{
public:
- typedef ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> HEAP_ITERATOR;
- friend class ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>;
+ typedef ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> HEAP_ITERATOR;
+ friend class ACE_Timer_Heap_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>;
- typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> INHERITED;
+ typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> INHERITED;
// = Initialization and termination methods.
/**
@@ -109,7 +110,8 @@ public:
ACE_Timer_Heap_T (size_t size,
bool preallocated = false,
FUNCTOR *upcall_functor = 0,
- ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0);
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0,
+ TIME_POLICY const & time_policy = TIME_POLICY());
/**
* Default constructor. @c upcall_functor is the instance of the
@@ -119,7 +121,8 @@ public:
* size will be ACE_DEFAULT_TIMERS and there will be no preallocation.
*/
ACE_Timer_Heap_T (FUNCTOR *upcall_functor = 0,
- ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0);
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0,
+ TIME_POLICY const & time_policy = TIME_POLICY());
/// Destructor.
virtual ~ACE_Timer_Heap_T (void);
@@ -318,10 +321,6 @@ private:
/// Set of pointers to the arrays of preallocated timer nodes.
/// Used to delete the allocated memory when required.
ACE_Unbounded_Set<ACE_Timer_Node_T<TYPE> *> preallocated_node_set_;
-
- // = Don't allow these operations for now.
- ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Heap_T (const ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK> &))
- ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK> &))
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Timer_List.h b/ACE/ace/Timer_List.h
index 0bc689465ea..3d900d5582e 100644
--- a/ACE/ace/Timer_List.h
+++ b/ACE/ace/Timer_List.h
@@ -33,7 +33,8 @@ typedef ACE_Timer_List_T<ACE_Event_Handler *,
typedef ACE_Timer_List_Iterator_T<ACE_Event_Handler *,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,
- ACE_SYNCH_RECURSIVE_MUTEX>
+ ACE_SYNCH_RECURSIVE_MUTEX,
+ ACE_Default_Time_Policy>
ACE_Timer_List_Iterator;
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Timer_List_T.cpp b/ACE/ace/Timer_List_T.cpp
index e2313d0e002..bf95530fa35 100644
--- a/ACE/ace/Timer_List_T.cpp
+++ b/ACE/ace/Timer_List_T.cpp
@@ -15,30 +15,30 @@ ACE_RCSID(ace, Timer_List_T, "$Id$")
// Default Constructor
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_List_Iterator_T (List& lst)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_List_Iterator_T (List& lst)
: list_ (lst)
{
this->first();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_List_Iterator_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::~ACE_Timer_List_Iterator_T (void)
{
}
// Positions the iterator at the node right after the dummy node
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::first (void)
{
this->current_node_ = this->list_.get_first();
}
// Positions the iterator at the next node in the Timer Queue
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::next (void)
{
// Make sure that if we are at the end, we don't wrap around
if (! this->isdone())
@@ -49,16 +49,16 @@ ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
// Returns true when we are at <head_>
-template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
-ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> bool
+ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::isdone (void) const
{
return this->current_node_ == 0;
}
// Returns the node at <position_> or 0 if we are at the end
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_List_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_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::item (void)
{
if (! this->isdone())
return this->current_node_;
@@ -70,8 +70,8 @@ ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::item (void)
// Return our instance of the iterator
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::iter (void)
{
this->iterator_->first ();
return *this->iterator_;
@@ -79,8 +79,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
// Create an empty list.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_List_T (FUNCTOR* uf, FreeList* fl)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_List_T (FUNCTOR* uf, FreeList* fl)
: Base(uf, fl)
, head_ (new ACE_Timer_Node_T<TYPE>)
, id_counter_ (0)
@@ -96,8 +96,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_List_T (FUNCTOR* uf, FreeLi
// Checks if list is empty.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> bool
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::is_empty (void) const
{
ACE_TRACE ("ACE_Timer_List_T::is_empty");
return this->get_first_i() == 0;
@@ -106,8 +106,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
// Returns earliest time in a non-empty list.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> const ACE_Time_Value &
-ACE_Timer_List_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_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::earliest_time (void) const
{
ACE_TRACE ("ACE_Timer_List_T::earliest_time");
ACE_Timer_Node_T<TYPE>* first = this->get_first_i();
@@ -119,8 +119,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const
// Remove all remaining items in the list.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_List_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::~ACE_Timer_List_T (void)
{
ACE_TRACE ("ACE_Timer_List_T::~ACE_Timer_List_T");
ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
@@ -150,8 +150,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_List_T (void)
delete this->head_;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Timer_List_T::dump");
@@ -175,8 +175,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
// Reschedule a periodic timer. This function must be called with the
// lock held.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE>* n)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reschedule (ACE_Timer_Node_T<TYPE>* n)
{
ACE_TRACE ("ACE_Timer_List_T::reschedule");
this->schedule_i(n, n->get_timer_value());
@@ -186,8 +186,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE>* n
// 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> long
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (const TYPE &type,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> long
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::schedule_i (const TYPE &type,
const void *act,
const ACE_Time_Value &future_time,
const ACE_Time_Value &interval)
@@ -213,8 +213,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (const TYPE &type,
}
/// The shared scheduling functionality between schedule() and reschedule()
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (ACE_Timer_Node_T<TYPE>* n,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::schedule_i (ACE_Timer_Node_T<TYPE>* n,
const ACE_Time_Value& expire)
{
if (this->is_empty()) {
@@ -240,9 +240,9 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (ACE_Timer_Node_T<TYPE>* n
p->set_next(n);
}
-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_List_T<TYPE, FUNCTOR, ACE_LOCK>::find_node (long timer_id) const
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::find_node (long timer_id) const
{
ACE_Timer_Node_T<TYPE>* n = this->get_first_i();
if (n == 0)
@@ -257,8 +257,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::find_node (long timer_id) const
}
// Locate and update the inteval on the timer_id
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reset_interval (long timer_id,
const ACE_Time_Value &interval)
{
ACE_TRACE ("ACE_Timer_List_T::reset_interval");
@@ -273,8 +273,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
// Locate and remove the single <ACE_Event_Handler> with a value of
// @a timer_id from the timer queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel (long timer_id,
const void **act,
int skip_close)
{
@@ -310,8 +310,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
}
// Locate and remove all values of <handler> from the timer queue.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type, int skip_close)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel (const TYPE &type, int skip_close)
{
ACE_TRACE ("ACE_Timer_List_T::cancel");
@@ -365,8 +365,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type, int skip_cl
return num_canceled;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::unlink (ACE_Timer_Node_T<TYPE>* n)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::unlink (ACE_Timer_Node_T<TYPE>* n)
{
n->get_prev()->set_next(n->get_next());
n->get_next()->set_prev(n->get_prev());
@@ -375,23 +375,23 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::unlink (ACE_Timer_Node_T<TYPE>* n)
}
/// Shared subset of the two cancel() methods.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel_i (ACE_Timer_Node_T<TYPE>* n)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel_i (ACE_Timer_Node_T<TYPE>* n)
{
this->unlink (n);
this->free_node (n);
}
// Reads the first node on the list and returns it.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::get_first (void)
{
ACE_TRACE ("ACE_Timer_List_T::get_first");
return this->get_first_i();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::get_first_i (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::get_first_i (void) const
{
ACE_TRACE ("ACE_Timer_List_T::get_first_i");
ACE_Timer_Node_T<TYPE>* first = this->head_->get_next();
@@ -403,8 +403,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::get_first_i (void) const
// Removes the first node on the list and returns it.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::remove_first (void)
{
ACE_TRACE ("ACE_Timer_List_T::remove_first");
ACE_Timer_Node_T<TYPE>* first = this->get_first();
diff --git a/ACE/ace/Timer_List_T.h b/ACE/ace/Timer_List_T.h
index d4ec800340e..09439c37994 100644
--- a/ACE/ace/Timer_List_T.h
+++ b/ACE/ace/Timer_List_T.h
@@ -21,7 +21,7 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
// Forward declaration.
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
class ACE_Timer_List_T;
/**
@@ -32,12 +32,12 @@ class ACE_Timer_List_T;
* This is a generic iterator that can be used to visit every
* node of a timer queue.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
class ACE_Timer_List_Iterator_T
-: public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR, ACE_LOCK>
+ : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR, ACE_LOCK>
{
public:
- typedef ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK> List;
+ typedef ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> List;
/// Constructor.
ACE_Timer_List_Iterator_T (List& lst);
@@ -81,19 +81,19 @@ protected:
* ACE_Timer_Heap will perform substantially faster than the
* ACE_Timer_List.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-class ACE_Timer_List_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY = ACE_Default_Time_Policy>
+class ACE_Timer_List_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
{
public:
/// Type of iterator
- typedef ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> Iterator;
+ typedef ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> Iterator;
/// Iterator is a friend
- friend class ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>;
+ friend class ACE_Timer_List_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>;
typedef ACE_Timer_Node_T<TYPE> Node;
/// Type inherited from
- typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> Base;
+ typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> Base;
typedef ACE_Free_List<Node> FreeList;
// = Initialization and termination methods.
diff --git a/ACE/ace/Timer_Queue_T.cpp b/ACE/ace/Timer_Queue_T.cpp
index 2ac9a29e9aa..18d1d004695 100644
--- a/ACE/ace/Timer_Queue_T.cpp
+++ b/ACE/ace/Timer_Queue_T.cpp
@@ -72,8 +72,8 @@ ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Queue_Iterator_T
{
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Time_Value *
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_timeout (ACE_Time_Value *max_wait_time)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Time_Value *
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::calculate_timeout (ACE_Time_Value *max_wait_time)
{
ACE_TRACE ("ACE_Timer_Queue_T::calculate_timeout");
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, max_wait_time));
@@ -109,8 +109,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_timeout (ACE_Time_Value *m
}
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Time_Value *
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_timeout (ACE_Time_Value *max_wait_time,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Time_Value *
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::calculate_timeout (ACE_Time_Value *max_wait_time,
ACE_Time_Value *the_timeout)
{
ACE_TRACE ("ACE_Timer_Queue_T::calculate_timeout");
@@ -152,8 +152,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_timeout (ACE_Time_Value *m
return the_timeout;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Timer_Queue_T::dump");
@@ -164,10 +164,11 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
#endif /* ACE_HAS_DUMP */
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Queue_T (FUNCTOR *upcall_functor,
- ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
- : gettimeofday_ (ACE_OS::gettimeofday),
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Queue_T (FUNCTOR *upcall_functor,
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist,
+ TIME_POLICY const & time_policy)
+ : time_policy_ (time_policy),
delete_upcall_functor_ (upcall_functor == 0),
delete_free_list_ (freelist == 0),
timer_skew_ (0, ACE_TIMER_SKEW)
@@ -187,8 +188,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Queue_T (FUNCTOR *upcall_f
upcall_functor_ = upcall_functor;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Queue_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::~ACE_Timer_Queue_T (void)
{
ACE_TRACE ("ACE_Timer_Queue_T::~ACE_Timer_Queue_T");
@@ -200,26 +201,26 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Queue_T (void)
delete this->free_list_;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::alloc_node (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::alloc_node (void)
{
return this->free_list_->remove ();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::free_node (ACE_Timer_Node_T<TYPE> *node)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::free_node (ACE_Timer_Node_T<TYPE> *node)
{
this->free_list_->add (node);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_LOCK &
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::mutex (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_LOCK &
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::mutex (void)
{
return this->mutex_;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> long
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> long
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::schedule (const TYPE &type,
const void *act,
const ACE_Time_Value &future_time,
const ACE_Time_Value &interval)
@@ -248,8 +249,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
// Run the <handle_timeout> method for all Timers whose values are <=
// <cur_time>.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_time)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::expire (const ACE_Time_Value &cur_time)
{
ACE_TRACE ("ACE_Timer_Queue_T::expire");
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
@@ -283,8 +284,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_ti
return number_of_timers_expired;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dispatch_info_i (const ACE_Time_Value &cur_time,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::dispatch_info_i (const ACE_Time_Value &cur_time,
ACE_Timer_Node_Dispatch_Info_T<TYPE> &info)
{
ACE_TRACE ("ACE_Timer_Queue_T::dispatch_info_i");
@@ -327,8 +328,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dispatch_info_i (const ACE_Time_Valu
return 0;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::return_node (ACE_Timer_Node_T<TYPE> *node)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::return_node (ACE_Timer_Node_T<TYPE> *node)
{
ACE_MT (ACE_GUARD (ACE_LOCK, ace_mon, this->mutex_));
this->free_node (node);
diff --git a/ACE/ace/Timer_Queue_T.h b/ACE/ace/Timer_Queue_T.h
index 8aef637579e..2e02021139e 100644
--- a/ACE/ace/Timer_Queue_T.h
+++ b/ACE/ace/Timer_Queue_T.h
@@ -24,6 +24,8 @@
#include "ace/Event_Handler.h"
#include "ace/Time_Value.h"
+#include "ace/Time_Policy.h"
+#include "ace/Copy_Disabled.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -203,8 +205,9 @@ public:
* implementing specialized policies such as ACE_Timer_List
* and ACE_Timer_Heap.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY = ACE_Default_Time_Policy>
class ACE_Timer_Queue_T
+ : private ACE_Copy_Disabled
{
public:
/// Type of Iterator.
@@ -218,7 +221,8 @@ public:
* timer nodes. If 0, then a default freelist will be created.
*/
ACE_Timer_Queue_T (FUNCTOR *upcall_functor = 0,
- ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0);
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0,
+ TIME_POLICY const & time_policy = TIME_POLICY());
/// Destructor - make virtual for proper destruction of inherited
/// classes.
@@ -344,11 +348,11 @@ public:
* implementations of the timer queue to use special high resolution
* timers.
*/
- /* virtual */ ACE_Time_Value gettimeofday (void);
+ ACE_Time_Value gettimeofday (void);
/// Allows applications to control how the timer queue gets the time
/// of day.
- void gettimeofday (ACE_Time_Value (*gettimeofday)(void));
+ void set_time_policy(TIME_POLICY const & time_policy);
/// Determine the next event to timeout. Returns @a max if there are
/// no pending timers or if all pending timers are longer than max.
@@ -438,8 +442,8 @@ protected:
/// Class that implements a free list
ACE_Free_List<ACE_Timer_Node_T<TYPE> > *free_list_;
- /// Pointer to function that returns the current time of day.
- ACE_Time_Value (*gettimeofday_)(void);
+ /// The policy to return the current time of day
+ TIME_POLICY time_policy_;
/// Upcall functor
FUNCTOR *upcall_functor_;
@@ -457,10 +461,6 @@ private:
/// Adjusts for timer skew in various clocks.
ACE_Time_Value timer_skew_;
-
- // = Don't allow these operations for now.
- ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Queue_T (const ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> &))
- ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> &))
};
/**
diff --git a/ACE/ace/Timer_Queue_T.inl b/ACE/ace/Timer_Queue_T.inl
index 7275119e2e1..ce957fd29ce 100644
--- a/ACE/ace/Timer_Queue_T.inl
+++ b/ACE/ace/Timer_Queue_T.inl
@@ -132,20 +132,20 @@ ACE_Timer_Node_T<TYPE>::get_dispatch_info (ACE_Timer_Node_Dispatch_Info_T<TYPE>
this->interval_ > ACE_Time_Value::zero;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::timer_skew (const ACE_Time_Value &skew)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::timer_skew (const ACE_Time_Value &skew)
{
timer_skew_ = skew;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE const ACE_Time_Value &
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::timer_skew (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE const ACE_Time_Value &
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::timer_skew (void) const
{
return timer_skew_;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE int
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::expire (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE int
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::expire (void)
{
if (!this->is_empty ())
return this->expire (this->gettimeofday () + timer_skew_);
@@ -153,8 +153,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::expire (void)
return 0;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dispatch_info (const ACE_Time_Value &cur_time,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::dispatch_info (const ACE_Time_Value &cur_time,
ACE_Timer_Node_Dispatch_Info_T<TYPE> &info)
{
ACE_TRACE ("ACE_Timer_Queue_T::dispatch_info");
@@ -163,8 +163,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::dispatch_info (const ACE_Time_Value
return this->dispatch_info_i (cur_time, info);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::upcall (ACE_Timer_Node_Dispatch_Info_T<TYPE> &info,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::upcall (ACE_Timer_Node_Dispatch_Info_T<TYPE> &info,
const ACE_Time_Value &cur_time)
{
this->upcall_functor ().timeout (*this,
@@ -174,8 +174,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::upcall (ACE_Timer_Node_Dispatch_Info
cur_time);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::preinvoke (ACE_Timer_Node_Dispatch_Info_T<TYPE> &info,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::preinvoke (ACE_Timer_Node_Dispatch_Info_T<TYPE> &info,
const ACE_Time_Value &cur_time,
const void *&upcall_act)
{
@@ -187,8 +187,8 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::preinvoke (ACE_Timer_Node_Dispatch_I
upcall_act);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::postinvoke (ACE_Timer_Node_Dispatch_Info_T<TYPE> &info,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::postinvoke (ACE_Timer_Node_Dispatch_Info_T<TYPE> &info,
const ACE_Time_Value &cur_time,
const void *upcall_act)
{
@@ -200,21 +200,21 @@ ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::postinvoke (ACE_Timer_Node_Dispatch_
upcall_act);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE ACE_Time_Value
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::gettimeofday (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE ACE_Time_Value
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::gettimeofday (void)
{
// Invoke gettimeofday via pointer to function.
- return this->gettimeofday_ ();
+ return this->time_policy_ ();
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE void
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::gettimeofday (ACE_Time_Value (*gettimeofday)(void))
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE void
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::set_time_policy (TIME_POLICY const & rhs)
{
- this->gettimeofday_ = gettimeofday;
+ this->time_policy_ = rhs;
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_INLINE FUNCTOR &
-ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>::upcall_functor (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_INLINE FUNCTOR &
+ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::upcall_functor (void)
{
return *this->upcall_functor_;
}
diff --git a/ACE/ace/Timer_Queuefwd.h b/ACE/ace/Timer_Queuefwd.h
index 6e03204bdde..076bd761c2c 100644
--- a/ACE/ace/Timer_Queuefwd.h
+++ b/ACE/ace/Timer_Queuefwd.h
@@ -18,17 +18,19 @@
#include /**/ "ace/pre.h"
#include "ace/Synch_Traits.h"
+#include "ace/Time_Policy.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-template <class TYPE, class FUNCTOR, class ACE_LOCK> class ACE_Timer_Queue_T;
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename ACE_TIME_POLICY> class ACE_Timer_Queue_T;
template <class ACE_LOCK> class ACE_Event_Handler_Handle_Timeout_Upcall;
class ACE_Event_Handler;
typedef ACE_Timer_Queue_T<ACE_Event_Handler *,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,
- ACE_SYNCH_RECURSIVE_MUTEX>
+ ACE_SYNCH_RECURSIVE_MUTEX,
+ ACE_Default_Time_Policy>
ACE_Timer_Queue;
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Timer_Wheel.h b/ACE/ace/Timer_Wheel.h
index 307e56b5542..0045e58dc6a 100644
--- a/ACE/ace/Timer_Wheel.h
+++ b/ACE/ace/Timer_Wheel.h
@@ -33,7 +33,8 @@ typedef ACE_Timer_Wheel_T<ACE_Event_Handler *,
typedef ACE_Timer_Wheel_Iterator_T<ACE_Event_Handler *,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,
- ACE_SYNCH_RECURSIVE_MUTEX>
+ ACE_SYNCH_RECURSIVE_MUTEX,
+ ACE_Default_Time_Policy>
ACE_Timer_Wheel_Iterator;
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Timer_Wheel_T.cpp b/ACE/ace/Timer_Wheel_T.cpp
index b860c1604dd..8ef6e654664 100644
--- a/ACE/ace/Timer_Wheel_T.cpp
+++ b/ACE/ace/Timer_Wheel_T.cpp
@@ -41,12 +41,13 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
* @param upcall_functor A pointer to a functor to use instead of the default
* @param freelist A pointer to a freelist to use instead of the default
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Wheel_T
(FUNCTOR* upcall_functor
, FreeList* freelist
+ , TIME_POLICY const & time_policy
)
-: Base (upcall_functor, freelist)
+ : Base (upcall_functor, freelist, time_policy)
, spokes_(0)
, spoke_count_(0) // calculated in open_i
, spoke_bits_(0)
@@ -71,14 +72,15 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T
* @param upcall_functor A pointer to a functor to use instead of the default
* @param freelist A pointer to a freelist to use instead of the default
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Wheel_T
(u_int spoke_count,
u_int resolution,
size_t prealloc,
FUNCTOR* upcall_functor,
- FreeList* freelist)
-: Base (upcall_functor, freelist)
+ FreeList* freelist,
+ TIME_POLICY const & time_policy)
+: Base (upcall_functor, freelist, time_policy)
, spokes_ (0)
, spoke_count_ (0) // calculated in open_i
, spoke_bits_ (0)
@@ -91,8 +93,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T
this->open_i (prealloc, spoke_count, resolution);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::power2bits (int n,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::power2bits (int n,
int min_bits,
int max_bits)
{
@@ -127,14 +129,12 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::power2bits (int n,
* Initialize the queue. Uses the established members for all needed
* information.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::open_i
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::open_i
(size_t prealloc, u_int spokes, u_int res)
{
ACE_TRACE ("ACE_Timer_Wheel_T::open_i");
- this->gettimeofday (ACE_OS::gettimeofday);
-
// Rather than waste bits in our timer id, we might as well round up
// the spoke count to the next power of two - 1 . (i.e 1,3,7,15,...127,etc.)
const int MIN_SPOKE_BITS = 3; // Allow between 8 and 4096 spokes
@@ -164,8 +164,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::open_i
}
/// Destructor just cleans up its memory
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Wheel_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::~ACE_Timer_Wheel_T (void)
{
ACE_TRACE ("ACE_Timer_Wheel_T::~ACE_Timer_Wheel_T");
@@ -190,9 +190,9 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Wheel_T (void)
}
/// Searches for a node by timer_id within one spoke.
-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_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::find_spoke_node
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::find_spoke_node
(u_int spoke, long timer_id) const
{
ACE_Timer_Node_T<TYPE>* root = this->spokes_[spoke];
@@ -208,9 +208,9 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::find_spoke_node
/// Searches all spokes for a node matching the specified timer_id
/// Uses the spoke encoded in the timer_id as a starting place.
-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_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::find_node (long timer_id) const
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::find_node (long timer_id) const
{
if (timer_id == -1)
return 0;
@@ -244,8 +244,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::find_node (long timer_id) const
*
* @return True if empty
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> bool
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::is_empty (void) const
{
ACE_TRACE ("ACE_Timer_Wheel_T::is_empty");
return timer_count_ == 0;
@@ -255,8 +255,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const
/**
* @return First (earliest) node in the wheel_'s earliest_spoke_ list
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> const ACE_Time_Value &
-ACE_Timer_Wheel_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_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::earliest_time (void) const
{
ACE_TRACE ("ACE_Timer_Wheel_T::earliest_time");
ACE_Timer_Node_T<TYPE>* n = this->get_first_i ();
@@ -268,8 +268,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const
/// Uses a simple hash to find which spoke to use based on when the
/// timer is due to expire. Hopefully the 64bit int operations avoid
/// any overflow problems.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> u_int
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_spoke
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> u_int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::calculate_spoke
(const ACE_Time_Value& t) const
{
return static_cast<u_int> ((t.msec () >> this->res_bits_) & (this->spoke_count_ - 1));
@@ -280,8 +280,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::calculate_spoke
/// have to do exhaustive searches within the spoke to ensure that a particular
/// timer id is not already in use. Some optimizations are in place so
/// that this hopefully doesn't have to happen often.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> long
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::generate_timer_id (u_int spoke)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> long
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::generate_timer_id (u_int spoke)
{
int cnt_bits = sizeof (long) * 8 - this->spoke_bits_;
@@ -382,8 +382,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::generate_timer_id (u_int spoke)
* @return Unique identifier (can be used to cancel the timer).
* -1 on failure.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> long
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (const TYPE& type,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> long
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::schedule_i (const TYPE& type,
const void* act,
const ACE_Time_Value& future_time,
const ACE_Time_Value& interval)
@@ -418,8 +418,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i (const TYPE& type,
*
* @param n The timer node to reschedule
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE>* n)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reschedule (ACE_Timer_Node_T<TYPE>* n)
{
ACE_TRACE ("ACE_Timer_Wheel_T::reschedule");
const ACE_Time_Value& expire = n->get_timer_value ();
@@ -428,8 +428,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE>*
}
/// The shared scheduling functionality between schedule() and reschedule()
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::schedule_i
(ACE_Timer_Node_T<TYPE>* n,
u_int spoke,
const ACE_Time_Value& expire)
@@ -476,8 +476,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule_i
*
* @return 0 if successful, -1 if no.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::reset_interval (long timer_id,
const ACE_Time_Value &interval
)
{
@@ -506,8 +506,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id,
*
* @return Number of timers cancelled
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE& type, int skip_close)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel (const TYPE& type, int skip_close)
{
ACE_TRACE ("ACE_Timer_Wheel_T::cancel");
@@ -589,8 +589,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE& type, int skip_c
* @return 1 for sucess and 0 if the timer_id wasn't found (or was
* found to be invalid)
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel (long timer_id,
const void **act,
int skip_close)
{
@@ -631,8 +631,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
}
/// Shared subset of the two cancel() methods.
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel_i (ACE_Timer_Node_T<TYPE>* n)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::cancel_i (ACE_Timer_Node_T<TYPE>* n)
{
this->unlink (n);
this->free_node (n);
@@ -644,8 +644,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel_i (ACE_Timer_Node_T<TYPE>* n)
/// determined from their expiration time.
/// The last time is always passed in, even though you can often calculate
/// it as get_first()->get_timer_value().
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::recalc_earliest
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::recalc_earliest
(const ACE_Time_Value& last)
{
// This is possible because we use a count for is_empty()
@@ -687,8 +687,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::recalc_earliest
* Dumps out the size of the wheel, the resolution, and the contents
* of the wheel.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Timer_Wheel_T::dump");
@@ -723,15 +723,15 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
*
* @return The earliest timer node.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::remove_first (void)
{
ACE_TRACE ("ACE_Timer_Wheel_T::remove_first");
return remove_first_expired (ACE_Time_Value::max_time);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::unlink (ACE_Timer_Node_T<TYPE>* n)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::unlink (ACE_Timer_Node_T<TYPE>* n)
{
ACE_TRACE ("ACE_Timer_Wheel_T::unlink");
--timer_count_;
@@ -741,8 +741,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::unlink (ACE_Timer_Node_T<TYPE>* n)
n->set_next (0);
}
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first_expired (const ACE_Time_Value& now)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> ACE_Timer_Node_T<TYPE> *
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::remove_first_expired (const ACE_Time_Value& now)
{
ACE_Timer_Node_T<TYPE>* n = this->get_first ();
if (n != 0 && n->get_timer_value() <= now)
@@ -759,17 +759,17 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first_expired (const ACE_Time
*
* @return The earliest timer node.
*/
-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_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void)
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::get_first (void)
{
ACE_TRACE ("ACE_Timer_Wheel_T::get_first");
return this->get_first_i ();
}
-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_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::get_first_i (void) const
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::get_first_i (void) const
{
ACE_Timer_Node_T<TYPE>* root = this->spokes_[this->earliest_spoke_];
ACE_Timer_Node_T<TYPE>* first = root->get_next ();
@@ -782,9 +782,9 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::get_first_i (void) const
/**
* @return The iterator
*/
-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_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::iter (void)
{
this->iterator_->first ();
return *this->iterator_;
@@ -794,8 +794,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)
* Dummy version of expire to get rid of warnings in Sun CC 4.2
* Just call the expire of the base class.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire ()
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::expire ()
{
return ACE_Timer_Queue_T<TYPE,FUNCTOR,ACE_LOCK>::expire ();
}
@@ -808,8 +808,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire ()
*
* @return Number of timers expired
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> int
-ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value& cur_time)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> int
+ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::expire (const ACE_Time_Value& cur_time)
{
ACE_TRACE ("ACE_Timer_Wheel_T::expire");
@@ -869,8 +869,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value& cur_ti
*
* @param wheel A reference for a timer queue to iterate over
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Wheel_Iterator_T<TYPE,FUNCTOR,ACE_LOCK>::ACE_Timer_Wheel_Iterator_T
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Wheel_Iterator_T<TYPE,FUNCTOR,ACE_LOCK,TIME_POLICY>::ACE_Timer_Wheel_Iterator_T
(Wheel& wheel)
: timer_wheel_ (wheel)
{
@@ -881,10 +881,8 @@ ACE_Timer_Wheel_Iterator_T<TYPE,FUNCTOR,ACE_LOCK>::ACE_Timer_Wheel_Iterator_T
/**
* Destructor, at this level does nothing.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-ACE_Timer_Wheel_Iterator_T<TYPE,
-FUNCTOR,
-ACE_LOCK>::~ACE_Timer_Wheel_Iterator_T (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
+ACE_Timer_Wheel_Iterator_T<TYPE,FUNCTOR,ACE_LOCK,TIME_POLICY>::~ACE_Timer_Wheel_Iterator_T (void)
{
}
@@ -897,8 +895,8 @@ ACE_LOCK>::~ACE_Timer_Wheel_Iterator_T (void)
* If the wheel is empty, spoke_ will be equal timer_wheel_.spoke_count_ and
* current_node_ would be 0.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::first (void)
{
this->goto_next(0);
}
@@ -907,8 +905,8 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::first (void)
/**
* Positions the iterator at the next node.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::next (void)
{
if (this->isdone())
return;
@@ -922,8 +920,8 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::next (void)
}
/// Helper class for common functionality of next() and first()
-template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::goto_next (u_int start_spoke)
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> void
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::goto_next (u_int start_spoke)
{
// Find the first non-empty entry.
u_int sc = this->timer_wheel_.spoke_count_;
@@ -946,8 +944,8 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::goto_next (u_int start_spok
/**
* @return True when we there aren't any more items (when current_node_ == 0)
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> bool
-ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) const
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY> bool
+ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::isdone (void) const
{
return this->current_node_ == 0;
}
@@ -956,8 +954,8 @@ ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>::isdone (void) const
* @return The node at the current spokeition in the sequence or 0 if the wheel
* is empty
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK> ACE_Timer_Node_T<TYPE> *
-ACE_Timer_Wheel_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_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::item (void)
{
return this->current_node_;
}
diff --git a/ACE/ace/Timer_Wheel_T.h b/ACE/ace/Timer_Wheel_T.h
index 40179f7a734..d879cacb9eb 100644
--- a/ACE/ace/Timer_Wheel_T.h
+++ b/ACE/ace/Timer_Wheel_T.h
@@ -15,6 +15,7 @@
#include /**/ "ace/pre.h"
#include "ace/Timer_Queue_T.h"
+#include "ace/Copy_Disabled.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
@@ -23,7 +24,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Forward declaration
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
class ACE_Timer_Wheel_T;
/**
@@ -35,12 +36,12 @@ class ACE_Timer_Wheel_T;
* node of a timer queue. Be aware that it doesn't traverse
* in the order of timeout values.
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY>
class ACE_Timer_Wheel_Iterator_T
: public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR, ACE_LOCK>
{
public:
- typedef ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> Wheel;
+ typedef ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> Wheel;
typedef ACE_Timer_Node_T<TYPE> Node;
/// Constructor
@@ -88,28 +89,31 @@ private:
* Timer Facilities"
* (http://dworkin.wustl.edu/~varghese/PAPERS/newbsd.ps.Z)
*/
-template <class TYPE, class FUNCTOR, class ACE_LOCK>
-class ACE_Timer_Wheel_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>
+template <class TYPE, class FUNCTOR, class ACE_LOCK, typename TIME_POLICY = ACE_Default_Time_Policy>
+class ACE_Timer_Wheel_T
+ : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>
{
public:
/// Type of iterator
- typedef ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> Iterator;
+ typedef ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> Iterator;
/// Iterator is a friend
- friend class ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK>;
+ friend class ACE_Timer_Wheel_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>;
typedef ACE_Timer_Node_T<TYPE> Node;
/// Type inherited from
- typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> Base;
+ typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY> Base;
typedef ACE_Free_List<Node> FreeList;
/// Default constructor
- ACE_Timer_Wheel_T (FUNCTOR* upcall_functor = 0, FreeList* freelist = 0);
+ ACE_Timer_Wheel_T (FUNCTOR* upcall_functor = 0, FreeList* freelist = 0,
+ TIME_POLICY const & time_policy = TIME_POLICY());
/// Constructor with opportunities to set the wheelsize and resolution
ACE_Timer_Wheel_T (u_int spoke_count,
u_int resolution,
size_t prealloc = 0,
FUNCTOR* upcall_functor = 0,
- FreeList* freelist = 0);
+ FreeList* freelist = 0,
+ TIME_POLICY const & time_policy = TIME_POLICY());
/// Destructor
virtual ~ACE_Timer_Wheel_T (void);
@@ -205,11 +209,6 @@ private:
ACE_Time_Value wheel_time_;
/// The total number of timers currently scheduled.
u_int timer_count_;
-
- // = Don't allow these operations for now, don't split into multiple lines
- // breaks sun compilers
- ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Wheel_T (const ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> &))
- ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> &))
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/ace.mpc b/ACE/ace/ace.mpc
index fbc2424a2ed..06c49df8fa3 100644
--- a/ACE/ace/ace.mpc
+++ b/ACE/ace/ace.mpc
@@ -260,6 +260,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf,
Thread_Mutex.cpp
Thread_Semaphore.cpp
Throughput_Stats.cpp
+ Time_Policy.cpp
Time_Value.cpp
Timeprobe.cpp
TLI.cpp
diff --git a/ACE/tests/Timer_Queue_Test.cpp b/ACE/tests/Timer_Queue_Test.cpp
index f6a76ee3465..b267237018d 100644
--- a/ACE/tests/Timer_Queue_Test.cpp
+++ b/ACE/tests/Timer_Queue_Test.cpp
@@ -32,6 +32,7 @@
#include "ace/Timer_Wheel.h"
#include "ace/Timer_Hash.h"
#include "ace/Timer_Queue.h"
+#include "ace/Time_Policy.h"
#include "ace/Recursive_Thread_Mutex.h"
#include "ace/Null_Mutex.h"
#include "ace/OS_NS_unistd.h"
@@ -626,8 +627,14 @@ run_main (int argc, ACE_TCHAR *argv[])
// Timer_Heap without preallocated memory, using high-res time.
(void) ACE_High_Res_Timer::global_scale_factor ();
- ACE_Timer_Heap *tq_heap = new ACE_Timer_Heap;
- tq_heap->gettimeofday (&ACE_High_Res_Timer::gettimeofday_hr);
+ typedef ACE_Timer_Heap_T<
+ ACE_Event_Handler*,
+ ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,
+ ACE_SYNCH_RECURSIVE_MUTEX,
+ ACE_FPointer_Time_Policy > Timer_Heap;
+
+ Timer_Heap *tq_heap = new Timer_Heap;
+ tq_heap->set_time_policy(&ACE_High_Res_Timer::gettimeofday_hr);
ACE_NEW_RETURN (tq_stack,
Timer_Queue_Stack (tq_heap,
ACE_TEXT ("ACE_Timer_Heap (high-res timer)"),