summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1999-08-18 02:02:27 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1999-08-18 02:02:27 +0000
commitf593e1cd3d92bd697776af6773e614cd404aeb32 (patch)
tree1134f3b4450a94e87c9f485fa77213ff8a1b2905 /ace
parent3e94ae019f94e693db519bfa4fbea86242f2bae6 (diff)
downloadATCD-f593e1cd3d92bd697776af6773e614cd404aeb32.tar.gz
ChangeLogTag:Tue Aug 17 20:02:55 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r--ace/FlReactor.cpp29
-rw-r--r--ace/FlReactor.h6
-rw-r--r--ace/Msg_WFMO_Reactor.h8
-rw-r--r--ace/Reactor.h35
-rw-r--r--ace/Reactor.i12
-rw-r--r--ace/Reactor_Impl.h35
-rw-r--r--ace/Select_Reactor_T.cpp20
-rw-r--r--ace/Select_Reactor_T.h33
-rw-r--r--ace/TP_Reactor.cpp5
-rw-r--r--ace/TP_Reactor.h2
-rw-r--r--ace/TP_Reactor.i5
-rw-r--r--ace/Timer_Hash_T.cpp60
-rw-r--r--ace/Timer_Hash_T.h25
-rw-r--r--ace/Timer_Heap_T.cpp68
-rw-r--r--ace/Timer_Heap_T.h34
-rw-r--r--ace/Timer_List_T.cpp59
-rw-r--r--ace/Timer_List_T.h34
-rw-r--r--ace/Timer_Queue_T.h36
-rw-r--r--ace/Timer_Wheel_T.cpp45
-rw-r--r--ace/Timer_Wheel_T.h25
-rw-r--r--ace/TkReactor.cpp21
-rw-r--r--ace/TkReactor.h6
-rw-r--r--ace/WFMO_Reactor.h33
-rw-r--r--ace/WFMO_Reactor.i23
-rw-r--r--ace/XtReactor.cpp21
-rw-r--r--ace/XtReactor.h5
26 files changed, 450 insertions, 235 deletions
diff --git a/ace/FlReactor.cpp b/ace/FlReactor.cpp
index 6759770eee4..6911d11336b 100644
--- a/ace/FlReactor.cpp
+++ b/ace/FlReactor.cpp
@@ -233,8 +233,8 @@ ACE_FlReactor::remove_handler_i (const ACE_Handle_Set &handles,
mask);
}
-// The following functions ensure that there is an Fl timeout for the
-// first timeout in the Reactor's Timer_Queue.
+// The following function ensures there's an Fl timeout for the first
+// timeout in the Reactor's Timer_Queue.
void
ACE_FlReactor::reset_timeout (void)
@@ -246,7 +246,30 @@ ACE_FlReactor::reset_timeout (void)
{
float t = max_wait_time->sec ()
+ max_wait_time->usec () / 1000000.0F;
- Fl::add_timeout (t, ACE_FlReactor::fl_timeout_proc, this);
+ Fl::add_timeout (t,
+ ACE_FlReactor::fl_timeout_proc,
+ this);
+ }
+}
+
+int
+ACE_FlReactor::reset_timer_interval
+ (const long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_FlReactor::reset_timer_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ int result = ACE_Select_Reactor::reset_interval
+ (timer_id,
+ interval);
+
+ if (result == -1)
+ return -1;
+ else
+ {
+ this->reset_timeout ();
+ return result;
}
}
diff --git a/ace/FlReactor.h b/ace/FlReactor.h
index 93519596657..454e09d51d1 100644
--- a/ace/FlReactor.h
+++ b/ace/FlReactor.h
@@ -58,10 +58,10 @@ public:
const void *arg,
const ACE_Time_Value &delta_time,
const ACE_Time_Value &interval);
-
+ virtual int reset_timer_interval (const long timer_id,
+ const ACE_Time_Value &interval);
virtual int cancel_timer (ACE_Event_Handler *handler,
int dont_call_handle_close = 1);
-
virtual int cancel_timer (long timer_id,
const void **arg = 0,
int dont_call_handle_close = 1);
@@ -92,6 +92,8 @@ protected:
private:
void reset_timeout (void);
+ // This method ensures there's an Fl timeout for the first timeout
+ // in the Reactor's Timer_Queue.
// = Integrate with the FL callback function mechanism.
static void fl_io_proc (int fd, void*);
diff --git a/ace/Msg_WFMO_Reactor.h b/ace/Msg_WFMO_Reactor.h
index ed690e11572..0002c6f6c45 100644
--- a/ace/Msg_WFMO_Reactor.h
+++ b/ace/Msg_WFMO_Reactor.h
@@ -10,8 +10,8 @@
// Msg_WFMO_Reactor.h
//
// = AUTHOR
-// Beskrovny Evgeny, Comverse Network Systems (evgeny_beskrovny@icomverse.com)
-// Irfan Pyarali, Washington University (irfan@cs.wustl.edu)
+// Beskrovny Evgeny <evgeny_beskrovny@icomverse.com> and
+// Irfan Pyarali <irfan@cs.wustl.edu>
//
// ============================================================================
@@ -28,20 +28,16 @@
class ACE_Export ACE_Msg_WFMO_Reactor : public ACE_WFMO_Reactor
{
- //
// = TITLE
- //
// An object oriented event demultiplexor and event handler
// dispatcher for Win32 MsgWaitForMultipleObjects.
//
// = DESCRIPTION
- //
// The ACE_Msg_WFMO_Reactor is an object-oriented event
// demultiplexor and event handler Reactor. It differs from
// WFMO_Reactor by its ability to react on Windows messages. It
// is needed when the task should serve also as a COM/DCOM
// server.
- //
public:
// = Initialization and termination methods.
ACE_Msg_WFMO_Reactor (ACE_Sig_Handler * = 0,
diff --git a/ace/Reactor.h b/ace/Reactor.h
index ac70c9c01ee..38274d31d52 100644
--- a/ace/Reactor.h
+++ b/ace/Reactor.h
@@ -333,25 +333,34 @@ public:
virtual int resume_handlers (void);
// Resume all <handles>.
- // Timer management.
+ // = Timer management.
virtual long schedule_timer (ACE_Event_Handler *event_handler,
const void *arg,
const ACE_Time_Value &delta,
const ACE_Time_Value &interval = ACE_Time_Value::zero);
// Schedule an <event_handler> that will expire after <delay> amount
- // of time. If it expires then <arg> is passed in as the value to
- // the <event_handler>'s <handle_timeout> callback method. If
- // <interval> is != to <ACE_Time_Value::zero> then it is used to
- // reschedule the <event_handler> automatically. This method
- // returns a <timer_id> that uniquely identifies the <event_handler>
- // in an internal list. This <timer_id> can be used to cancel an
- // <event_handler> before it expires. The cancellation ensures that
- // <timer_ids> are unique up to values of greater than 2 billion
- // timers. As long as timers don't stay around longer than this
- // there should be no problems with accidentally deleting the wrong
- // timer. Returns -1 on failure (which is guaranteed never to be a
- // valid <timer_id>.
+ // of time, which is specified as relative time to the current
+ // <gettimeofday>. If it expires then <arg> is passed in as the
+ // value to the <event_handler>'s <handle_timeout> callback method.
+ // If <interval> is != to <ACE_Time_Value::zero> then it is used to
+ // reschedule the <event_handler> automatically, also specified
+ // using relative time. This method returns a <timer_id> that
+ // uniquely identifies the <event_handler> in an internal list.
+ // This <timer_id> can be used to cancel an <event_handler> before
+ // it expires. The cancellation ensures that <timer_ids> are unique
+ // up to values of greater than 2 billion timers. As long as timers
+ // don't stay around longer than this there should be no problems
+ // with accidentally deleting the wrong timer. Returns -1 on
+ // failure (which is guaranteed never to be a valid <timer_id>.
+
+ virtual int reset_timer_interval (const long timer_id,
+ const ACE_Time_Value &interval);
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel_timer (ACE_Event_Handler *event_handler,
int dont_call_handle_close = 1);
diff --git a/ace/Reactor.i b/ace/Reactor.i
index c197c7f325a..0ff7125d0bc 100644
--- a/ace/Reactor.i
+++ b/ace/Reactor.i
@@ -356,6 +356,18 @@ ACE_Reactor::resume_handlers (void)
}
+ACE_INLINE int
+ACE_Reactor::reset_timer_interval
+ (const long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Reactor::reset_timer_interval");
+
+ return this->implementation ()->reset_timer_interval
+ (timer_id,
+ interval);
+}
+
ACE_INLINE long
ACE_Reactor::schedule_timer (ACE_Event_Handler *event_handler,
const void *arg,
diff --git a/ace/Reactor_Impl.h b/ace/Reactor_Impl.h
index a28eed5641a..da8543f5c57 100644
--- a/ace/Reactor_Impl.h
+++ b/ace/Reactor_Impl.h
@@ -291,25 +291,34 @@ public:
// If we need to reset handles returned from accept/connect.
- // Timer management.
+ // = Timer management.
virtual long schedule_timer (ACE_Event_Handler *event_handler,
const void *arg,
const ACE_Time_Value &delta,
const ACE_Time_Value &interval = ACE_Time_Value::zero) = 0;
// Schedule an <event_handler> that will expire after <delay> amount
- // of time. If it expires then <arg> is passed in as the value to
- // the <event_handler>'s <handle_timeout> callback method. If
- // <interval> is != to <ACE_Time_Value::zero> then it is used to
- // reschedule the <event_handler> automatically. This method
- // returns a <timer_id> that uniquely identifies the <event_handler>
- // in an internal list. This <timer_id> can be used to cancel an
- // <event_handler> before it expires. The cancellation ensures that
- // <timer_ids> are unique up to values of greater than 2 billion
- // timers. As long as timers don't stay around longer than this
- // there should be no problems with accidentally deleting the wrong
- // timer. Returns -1 on failure (which is guaranteed never to be a
- // valid <timer_id>.
+ // of time, which is specified as relative time to the current
+ // <gettimeofday>. If it expires then <arg> is passed in as the
+ // value to the <event_handler>'s <handle_timeout> callback method.
+ // If <interval> is != to <ACE_Time_Value::zero> then it is used to
+ // reschedule the <event_handler> automatically, also using relative
+ // time. This method returns a <timer_id> that uniquely identifies
+ // the <event_handler> in an internal list. This <timer_id> can be
+ // used to cancel an <event_handler> before it expires. The
+ // cancellation ensures that <timer_ids> are unique up to values of
+ // greater than 2 billion timers. As long as timers don't stay
+ // around longer than this there should be no problems with
+ // accidentally deleting the wrong timer. Returns -1 on failure
+ // (which is guaranteed never to be a valid <timer_id>.
+
+ virtual int reset_timer_interval (const long timer_id,
+ const ACE_Time_Value &interval);
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel_timer (ACE_Event_Handler *event_handler,
int dont_call_handle_close = 1) = 0;
diff --git a/ace/Select_Reactor_T.cpp b/ace/Select_Reactor_T.cpp
index 4b0f649a52f..562b4b0410d 100644
--- a/ace/Select_Reactor_T.cpp
+++ b/ace/Select_Reactor_T.cpp
@@ -668,8 +668,6 @@ ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::remove_handler
return result;
}
-// Note the queue handles its own locking.
-
template <class ACE_SELECT_REACTOR_TOKEN> long
ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::schedule_timer
(ACE_Event_Handler *handler,
@@ -681,7 +679,23 @@ ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::schedule_timer
ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
return this->timer_queue_->schedule
- (handler, arg, timer_queue_->gettimeofday () + delta_time, interval);
+ (handler,
+ arg,
+ timer_queue_->gettimeofday () + delta_time,
+ interval);
+}
+
+template <class ACE_SELECT_REACTOR_TOKEN> int
+ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::reset_timer_interval
+ (const long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_Select_Reactor_T::reset_timer_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ return this->timer_queue_->reset_interval
+ (timer_id,
+ interval);
}
// Main event loop driver that blocks for <max_wait_time> before
diff --git a/ace/Select_Reactor_T.h b/ace/Select_Reactor_T.h
index 9763762d3a9..76be6e62a13 100644
--- a/ace/Select_Reactor_T.h
+++ b/ace/Select_Reactor_T.h
@@ -333,21 +333,30 @@ public:
// = Timer management.
virtual long schedule_timer (ACE_Event_Handler *,
const void *arg,
- const ACE_Time_Value &delta_time,
+ const ACE_Time_Value &delta,
const ACE_Time_Value &interval = ACE_Time_Value::zero);
- // Schedule an <event_handler> that will expire after <delta_time>
- // amount of time. If it expires then <arg> is passed in as the
+ // Schedule an <event_handler> that will expire after <delta> amount
+ // of time, which is specified as relative time to the current
+ // <gettimeofday>. If it expires then <arg> is passed in as the
// value to the <event_handler>'s <handle_timeout> callback method.
// If <interval> is != to <ACE_Time_Value::zero> then it is used to
- // reschedule the <event_handler> automatically. This method
- // returns a <timer_id> that uniquely identifies the <event_handler>
- // in an internal list. This <timer_id> can be used to cancel an
- // <event_handler> before it expires. The cancellation ensures that
- // <timer_ids> are unique up to values of greater than 2 billion
- // timers. As long as timers don't stay around longer than this
- // there should be no problems with accidentally deleting the wrong
- // timer. Returns -1 on failure (which is guaranteed never to be a
- // valid <timer_id>.
+ // reschedule the <event_handler> automatically, which is also
+ // specified using relative time. This method returns a <timer_id>
+ // that uniquely identifies the <event_handler> in an internal list.
+ // This <timer_id> can be used to cancel an <event_handler> before
+ // it expires. The cancellation ensures that <timer_ids> are unique
+ // up to values of greater than 2 billion timers. As long as timers
+ // don't stay around longer than this there should be no problems
+ // with accidentally deleting the wrong timer. Returns -1 on
+ // failure (which is guaranteed never to be a valid <timer_id>.
+
+ virtual int reset_timer_interval (const long timer_id,
+ const ACE_Time_Value &interval);
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel_timer (ACE_Event_Handler *event_handler,
int dont_call_handle_close = 1);
diff --git a/ace/TP_Reactor.cpp b/ace/TP_Reactor.cpp
index 1d856fe3037..edec959ebf8 100644
--- a/ace/TP_Reactor.cpp
+++ b/ace/TP_Reactor.cpp
@@ -57,8 +57,9 @@ ACE_TP_Reactor::notify_handle (ACE_EH_Dispatch_Info &dispatch_info)
// If positive, reschedule in Reactor
else if (status > 0)
- this->ready_ops (handle, mask, ACE_Reactor::SET_MASK);
-
+ this->ready_ops (handle,
+ mask,
+ ACE_Reactor::SET_MASK);
// assert (status >= 0);
// resume in Reactor
return (event_handler != this->notify_handler_ ?
diff --git a/ace/TP_Reactor.h b/ace/TP_Reactor.h
index 98ddd93f67d..6e4b86f23b3 100644
--- a/ace/TP_Reactor.h
+++ b/ace/TP_Reactor.h
@@ -69,12 +69,10 @@ public:
class ACE_Export ACE_TP_Reactor : public ACE_Select_Reactor
{
// = TITLE
- //
// Specialization of Select Reactor to support thread-pool based
// event dispatching.
//
// = DESCRIPTION
- //
// One of the short comings of the Select_Reactor in ACE is that
// it did not support a thread pool based event dispatching
// model, similar to the one in WFMO_Reactor. In
diff --git a/ace/TP_Reactor.i b/ace/TP_Reactor.i
index 602f9e89f7c..7705ccca58c 100644
--- a/ace/TP_Reactor.i
+++ b/ace/TP_Reactor.i
@@ -11,9 +11,12 @@ ACE_INLINE void
ACE_TP_Reactor::wakeup_all_threads (void)
{
ACE_MT (this->token_.signal_all_threads (););
+
// Send a notification, but don't block if there's no one to receive
// it.
- this->notify (0, ACE_Event_Handler::NULL_MASK, (ACE_Time_Value *) &ACE_Time_Value::zero);
+ this->notify (0,
+ ACE_Event_Handler::NULL_MASK,
+ (ACE_Time_Value *) &ACE_Time_Value::zero);
}
ACE_INLINE void
diff --git a/ace/Timer_Hash_T.cpp b/ace/Timer_Hash_T.cpp
index 3f6292924dd..bb166dbdb12 100644
--- a/ace/Timer_Hash_T.cpp
+++ b/ace/Timer_Hash_T.cpp
@@ -153,7 +153,9 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::next (void)
// If there is no more in the current bucket, go to the next
if (this->iter_->isdone ())
{
- for (this->position_++; this->position_ < this->timer_hash_.table_size_; this->position_++)
+ for (this->position_++;
+ this->position_ < this->timer_hash_.table_size_;
+ this->position_++)
{
// Check for an empty entry
if (!this->timer_hash_.table_[this->position_]->is_empty ())
@@ -164,7 +166,7 @@ ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::next (void)
}
}
- // Didn't find any
+ // Didn't find any.
this->iter_ = 0;
}
else
@@ -201,11 +203,11 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::iter (void)
template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (size_t table_size,
- FUNCTOR *upcall_functor,
- ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
+ FUNCTOR *upcall_functor,
+ ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
: ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> (upcall_functor, freelist),
size_ (0),
- table_ (new BUCKET* [table_size]),
+ table_ (new BUCKET *[table_size]),
table_size_ (table_size),
table_functor_ (this),
earliest_position_ (0)
@@ -214,7 +216,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (size_t tabl
this->gettimeofday (ACE_OS::gettimeofday);
- for (size_t i = 0; i < table_size; i++)
+ for (size_t i = 0;
+ i < table_size;
+ i++)
{
ACE_NEW (this->table_[i],
BUCKET (&this->table_functor_,
@@ -232,7 +236,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (FUNCTOR *up
ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist)
: ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> (upcall_functor, freelist),
size_ (0),
- table_ (new BUCKET* [ACE_DEFAULT_TIMER_HASH_TABLE_SIZE]),
+ table_ (new BUCKET *[ACE_DEFAULT_TIMER_HASH_TABLE_SIZE]),
table_size_ (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE),
table_functor_ (this),
earliest_position_ (0)
@@ -241,7 +245,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (FUNCTOR *up
this->gettimeofday (ACE_OS::gettimeofday);
- for (size_t i = 0; i < this->table_size_; i++)
+ for (size_t i = 0;
+ i < this->table_size_;
+ i++)
{
ACE_NEW (this->table_[i],
BUCKET (&this->table_functor_,
@@ -253,7 +259,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (FUNCTOR *up
HASH_ITERATOR (*this));
}
-
// Remove all remaining items in the Queue.
template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
@@ -264,7 +269,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::~ACE_Timer_Hash_T (void)
delete iterator_;
- for (size_t i = 0; i < this->table_size_; i++)
+ for (size_t i = 0;
+ i < this->table_size_;
+ i++)
delete this->table_[i];
delete [] this->table_;
@@ -295,9 +302,11 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\ntable_size_ = %d"), this->table_size_));
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nearliest_position_ = %d"), this->earliest_position_));
+
for (size_t i = 0; i < this->table_size_; i++)
- if (!this->table_[i]->is_empty ())
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nBucket %d contains nodes"), i));
+ if (!this->table_[i]->is_empty ())
+ ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nBucket %d contains nodes"), i));
+
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\n")));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
@@ -340,7 +349,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule (const TYPE &type,
ACE_TRACE ("ACE_Timer_Hash_T::schedule");
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
- size_t position = future_time.usec () % this->table_size_;
+ size_t position =
+ future_time.usec () % this->table_size_;
Hash_Token *h;
@@ -356,7 +366,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule (const TYPE &type,
interval);
if (this->table_[this->earliest_position_]->is_empty ()
- || this->table_[position]->earliest_time () < this->table_[this->earliest_position_]->earliest_time ())
+ || this->table_[position]->earliest_time ()
+ < this->table_[this->earliest_position_]->earliest_time ())
this->earliest_position_ = position;
++this->size_;
@@ -377,7 +388,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reset_interval (const long ti
// Make sure we are getting a valid <timer_id>, not an error
// returned by <schedule>.
if (timer_id == -1)
- return 0;
+ return -1;
Hash_Token *h = ACE_reinterpret_cast (Hash_Token *,
timer_id);
@@ -445,16 +456,19 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type,
i < this->table_size_;
i++)
{
- ACE_Timer_Queue_Iterator_T<TYPE, ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>, ACE_Null_Mutex> &iter =
+ ACE_Timer_Queue_Iterator_T<TYPE,
+ ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>,
+ ACE_Null_Mutex> &iter =
this->table_[i]->iter ();
for (iter.first ();
!iter.isdone ();
iter.next ())
if (iter.item ()->get_type () == type)
- timer_ids[pos++] = ACE_reinterpret_cast (Hash_Token *,
- ACE_const_cast (void *,
- iter.item ()->get_act ()));
+ timer_ids[pos++] =
+ ACE_reinterpret_cast (Hash_Token *,
+ ACE_const_cast (void *,
+ iter.item ()->get_act ()));
}
if (pos > this->size_)
@@ -472,8 +486,8 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type,
delete [] timer_ids;
if (dont_call == 0)
- this->upcall_functor ().cancellation (*this, type);
-
+ this->upcall_functor ().cancellation (*this,
+ type);
this->find_new_earliest ();
return pos;
@@ -574,21 +588,19 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire (const ACE_Time_Value
reclaim = 0;
}
- // call the functor
Hash_Token *h = ACE_reinterpret_cast (Hash_Token *,
ACE_const_cast (void *,
act));
+ // Call the functor.
this->upcall (type,
h->act_,
cur_time);
-
if (reclaim)
{
// Free up the node and the token
this->free_node (expired);
delete h;
}
-
number_of_timers_expired++;
}
}
diff --git a/ace/Timer_Hash_T.h b/ace/Timer_Hash_T.h
index 0e26816fb5a..67f5446e1d2 100644
--- a/ace/Timer_Hash_T.h
+++ b/ace/Timer_Hash_T.h
@@ -164,20 +164,23 @@ public:
const void *act,
const ACE_Time_Value &delay,
const ACE_Time_Value &interval = ACE_Time_Value::zero);
- // Schedule <type> that will expire after <delay> amount of time.
- // If it expires then <act> is passed in as the value to the
- // <functor>. If <interval> is != to <ACE_Time_Value::zero> then it
- // is used to reschedule the <type> automatically. This method
- // returns a <timer_id> that is a pointer to a token which stores
- // information about the event. This <timer_id> can be used to cancel
- // the timer before it expires. Returns -1 on failure.
+ // Schedule <type> that will expire after <delay> amount of time,
+ // which is specified in absolute time. If it expires then <act> is
+ // passed in as the value to the <functor>. If <interval> is != to
+ // <ACE_Time_Value::zero> then it is used to reschedule the <type>
+ // automatically, using relative time to the current <gettimeofday>.
+ // This method returns a <timer_id> that is a pointer to a token
+ // which stores information about the event. This <timer_id> can be
+ // used to cancel the timer before it expires. Returns -1 on
+ // failure.
virtual int reset_interval (const long timer_id,
const ACE_Time_Value &interval);
- // Resets the interval of the timer represented by <timer_id> to
- // <interval>. If <interval> is equal to <ACE_Time_Value::zero>,
- // the timer will become a non-rescheduling timer. Returns 1 if
- // successful, 0 if not.
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel (const TYPE &type,
int dont_call_handle_close = 1);
diff --git a/ace/Timer_Heap_T.cpp b/ace/Timer_Heap_T.cpp
index aecdbc21194..7d4ea508f3f 100644
--- a/ace/Timer_Heap_T.cpp
+++ b/ace/Timer_Heap_T.cpp
@@ -197,7 +197,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::pop_freelist (void)
ACE_TRACE ("ACE_Timer_Heap::pop_freelist");
// We need to truncate this to <int> for backwards compatibility.
- int new_id = (int) this->timer_ids_freelist_;
+ int new_id = ACE_static_cast (int,
+ this->timer_ids_freelist_);
// The freelist values in the <timer_ids_> are negative, so we need
// to negate them to get the next freelist "pointer."
@@ -282,13 +283,15 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const
}
template <class TYPE, class FUNCTOR, class ACE_LOCK> void
-ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::copy (int slot, ACE_Timer_Node_T<TYPE> *moved_node)
+ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::copy (int slot,
+ ACE_Timer_Node_T<TYPE> *moved_node)
{
// Insert <moved_node> into its new location in the heap.
this->heap_[slot] = moved_node;
ACE_ASSERT (moved_node->get_timer_id () >= 0
&& moved_node->get_timer_id () < (int) this->max_size_);
+
// Update the corresponding slot in the parallel <timer_ids_> array.
this->timer_ids_[moved_node->get_timer_id ()] = slot;
}
@@ -321,10 +324,15 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::remove (size_t slot)
// parent it needs be moved down the heap.
size_t parent = ACE_HEAP_PARENT (slot);
- if (moved_node->get_timer_value () >= this->heap_[parent]->get_timer_value ())
- this->reheap_down (moved_node, slot, ACE_HEAP_LCHILD (slot));
+ if (moved_node->get_timer_value ()
+ >= this->heap_[parent]->get_timer_value ())
+ this->reheap_down (moved_node,
+ slot,
+ ACE_HEAP_LCHILD (slot));
else
- this->reheap_up (moved_node, slot, parent);
+ this->reheap_up (moved_node,
+ slot,
+ parent);
}
return removed_node;
@@ -341,14 +349,17 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_down (ACE_Timer_Node_T<TYPE> *
{
// Choose the smaller of the two children.
if (child + 1 < this->cur_size_
- && this->heap_[child + 1]->get_timer_value () < this->heap_[child]->get_timer_value ())
+ && this->heap_[child + 1]->get_timer_value ()
+ < this->heap_[child]->get_timer_value ())
child++;
// Perform a <copy> if the child has a larger timeout value than
// the <moved_node>.
- if (this->heap_[child]->get_timer_value () < moved_node->get_timer_value ())
+ if (this->heap_[child]->get_timer_value ()
+ < moved_node->get_timer_value ())
{
- this->copy (slot, this->heap_[child]);
+ this->copy (slot,
+ this->heap_[child]);
slot = child;
child = ACE_HEAP_LCHILD (child);
}
@@ -362,8 +373,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_down (ACE_Timer_Node_T<TYPE> *
template <class TYPE, class FUNCTOR, class ACE_LOCK> void
ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_up (ACE_Timer_Node_T<TYPE> *moved_node,
- size_t slot,
- size_t parent)
+ size_t slot,
+ size_t parent)
{
// Restore the heap property after an insertion.
@@ -371,7 +382,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_up (ACE_Timer_Node_T<TYPE> *mo
{
// If the parent node is greater than the <moved_node> we need
// to copy it down.
- if (moved_node->get_timer_value () < this->heap_[parent]->get_timer_value ())
+ if (moved_node->get_timer_value ()
+ < this->heap_[parent]->get_timer_value ())
{
this->copy (slot, this->heap_[parent]);
slot = parent;
@@ -383,7 +395,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reheap_up (ACE_Timer_Node_T<TYPE> *mo
// Insert the new node into its proper resting place in the heap and
// update the corresponding slot in the parallel <timer_ids> array.
- this->copy (slot, moved_node);
+ this->copy (slot,
+ moved_node);
}
template <class TYPE, class FUNCTOR, class ACE_LOCK> void
@@ -442,8 +455,8 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::grow_heap (void)
// Grow the preallocation array (if using preallocation)
if (this->preallocated_nodes_ != 0)
{
- // Create a new array with max_size elements to link in
- // to existing list.
+ // Create a new array with max_size elements to link in to
+ // existing list.
#if defined (__IBMCPP__) && (__IBMCPP__ >= 400)
ACE_NEW (this->preallocated_nodes_,
ACE_Timer_Node_T<TYPE>[88]);
@@ -574,6 +587,7 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
interval,
0,
timer_id);
+
this->insert (temp);
return timer_id;
}
@@ -595,12 +609,14 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
// Locate the ACE_Timer_Node that corresponds to the timer_id.
// Check to see if the timer_id is out of range
- if (timer_id < 0 || (size_t) timer_id > this->max_size_)
+ if (timer_id < 0
+ || (size_t) timer_id > this->max_size_)
return 0;
long timer_node_slot = this->timer_ids_[timer_id];
- if (timer_node_slot < 0) // Check to see if timer_id is still valid.
+ // Check to see if timer_id is still valid.
+ if (timer_node_slot < 0)
return 0;
if (timer_id != this->heap_[timer_node_slot]->get_timer_id ())
@@ -610,11 +626,13 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
}
else
{
- ACE_Timer_Node_T<TYPE> *temp = this->remove (timer_node_slot);
+ ACE_Timer_Node_T<TYPE> *temp =
+ this->remove (timer_node_slot);
if (dont_call == 0)
// Call the close hook.
- this->upcall_functor ().cancellation (*this, temp->get_type ());
+ this->upcall_functor ().cancellation (*this,
+ temp->get_type ());
if (act != 0)
*act = temp->get_act ();
@@ -636,24 +654,26 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (const long timer_id,
// Locate the ACE_Timer_Node that corresponds to the timer_id.
// Check to see if the timer_id is out of range
- if (timer_id < 0 || (size_t) timer_id > this->max_size_)
- return 0;
+ if (timer_id < 0
+ || (size_t) timer_id > this->max_size_)
+ return -1;
long timer_node_slot = this->timer_ids_[timer_id];
- if (timer_node_slot < 0) // Check to see if timer_id is still valid.
- return 0;
+ // Check to see if timer_id is still valid.
+ if (timer_node_slot < 0)
+ return -1;
if (timer_id != this->heap_[timer_node_slot]->get_timer_id ())
{
ACE_ASSERT (timer_id == this->heap_[timer_node_slot]->get_timer_id ());
- return 0;
+ return -1;
}
else
{
// Reset the timer interval
this->heap_[timer_node_slot]->set_interval (interval);
- return 1;
+ return 0;
}
}
diff --git a/ace/Timer_Heap_T.h b/ace/Timer_Heap_T.h
index f75eced29e0..669d9757dae 100644
--- a/ace/Timer_Heap_T.h
+++ b/ace/Timer_Heap_T.h
@@ -121,25 +121,27 @@ public:
const void *act,
const ACE_Time_Value &delay,
const ACE_Time_Value &interval = ACE_Time_Value::zero);
- // Schedule <type> that will expire after <delay> amount of time.
- // If it expires then <act> is passed in as the value to the
- // <functor>. If <interval> is != to <ACE_Time_Value::zero> then it
- // is used to reschedule the <type> automatically. This method
- // returns a <timer_id> that uniquely identifies the the <type>
- // entry in an internal list. This <timer_id> can be used to cancel
- // the timer before it expires. The cancellation ensures that
- // <timer_ids> are unique up to values of greater than 2 billion
- // timers. As long as timers don't stay around longer than this
- // there should be no problems with accidentally deleting the wrong
- // timer. Returns -1 on failure (which is guaranteed never to be a
- // valid <timer_id>).
+ // Schedule <type> that will expire after <delay> amount of time,
+ // which is specified in absolute time. If it expires then <act> is
+ // passed in as the value to the <functor>. If <interval> is != to
+ // <ACE_Time_Value::zero> then it is used to reschedule the <type>
+ // automatically, using relative time to the current <gettimeofday>.
+ // This method returns a <timer_id> that uniquely identifies the the
+ // <type> entry in an internal list. This <timer_id> can be used to
+ // cancel the timer before it expires. The cancellation ensures
+ // that <timer_ids> are unique up to values of greater than 2
+ // billion timers. As long as timers don't stay around longer than
+ // this there should be no problems with accidentally deleting the
+ // wrong timer. Returns -1 on failure (which is guaranteed never to
+ // be a valid <timer_id>).
virtual int reset_interval (const long timer_id,
const ACE_Time_Value &interval);
- // Resets the interval of the timer represented by <timer_id> to
- // <interval>. If <interval> is equal to <ACE_Time_Value::zero>,
- // the timer will become a non-rescheduling timer. Returns 1 if
- // successful, 0 if not.
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel (const TYPE &type,
int dont_call_handle_close = 1);
diff --git a/ace/Timer_List_T.cpp b/ace/Timer_List_T.cpp
index b16d6eac1a1..f010b48a96b 100644
--- a/ace/Timer_List_T.cpp
+++ b/ace/Timer_List_T.cpp
@@ -83,6 +83,7 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_List_T (FUNCTOR *upcall_fun
timer_id_ (0)
{
ACE_TRACE ("ACE_Timer_List_T::ACE_Timer_List");
+
this->head_->set_next (this->head_);
this->head_->set_prev (this->head_);
@@ -121,12 +122,14 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_List_T (void)
delete iterator_;
- ACE_Timer_Node_T<TYPE> *curr = this->head_->get_next ();
-
- while (curr != this->head_)
+ for (ACE_Timer_Node_T<TYPE> *curr = this->head_->get_next ();
+ curr != this->head_;
+ )
{
ACE_Timer_Node_T<TYPE> *next = curr->get_next ();
- this->upcall_functor ().deletion (*this, next->get_type (), next->get_act ());
+ this->upcall_functor ().deletion (*this,
+ next->get_type (),
+ next->get_act ());
this->free_node (curr);
curr = next;
}
@@ -135,19 +138,19 @@ 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
{
ACE_TRACE ("ACE_Timer_List_T::dump");
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+
size_t count = 0;
- ACE_Timer_Node_T<TYPE> *curr = this->head_->get_next ();
- while (curr != this->head_)
- {
- count++;
- curr = curr->get_next ();
- }
+
+ for (ACE_Timer_Node_T<TYPE> *curr = this->head_->get_next ();
+ curr != this->head_;
+ curr = curr->get_next ())
+ count++;
+
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\nsize_ = %d"), count));
ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("\ntimer_id_ = %d"), this->timer_id_));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
@@ -193,7 +196,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
// ascending order of absolute time to expire).
ACE_Timer_Node_T<TYPE> *after = this->head_->get_next ();
- while (after != this->head_ && future_time > after->get_timer_value ())
+ while (after != this->head_
+ && future_time > after->get_timer_value ())
after = after->get_next ();
ACE_Timer_Node_T<TYPE> *temp = this->alloc_node ();
@@ -209,7 +213,7 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
after->get_prev ()->set_next (temp);
after->set_prev (temp);
- return (long) temp;
+ return ACE_reinterpret_cast (long, temp);
}
// Locate and update the inteval on the timer_id
@@ -222,15 +226,17 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (const long timer_id,
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
// Make sure we are getting a valid <timer_id>, not an error
- // returned by schedule ()
+ // returned by <schedule>.
if (timer_id == -1)
- return 0;
+ return -1;
- ACE_Timer_Node_T<TYPE> *node = (ACE_Timer_Node_T<TYPE> *) timer_id;
+ ACE_Timer_Node_T<TYPE> *node =
+ ACE_reinterpret_cast (ACE_Timer_Node_T<TYPE> *,
+ timer_id);
node->set_interval (interval);
- return 1;
+ return 0;
}
// Locate and remove the single <ACE_Event_Handler> with a value of
@@ -238,8 +244,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (const long timer_id,
template <class TYPE, class FUNCTOR, class ACE_LOCK> int
ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
- const void **act,
- int dont_call)
+ const void **act,
+ int dont_call)
{
ACE_TRACE ("ACE_Timer_List_T::cancel");
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
@@ -249,7 +255,9 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
if (timer_id == -1)
return 0;
- ACE_Timer_Node_T<TYPE> *node = (ACE_Timer_Node_T<TYPE> *) timer_id;
+ ACE_Timer_Node_T<TYPE> *node =
+ ACE_reinterpret_cast (ACE_Timer_Node_T<TYPE> *,
+ timer_id);
// Check to see if the node looks like a true ACE_Timer_Node_T<TYPE>
if (timer_id == node->get_timer_id ())
@@ -261,8 +269,8 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
*act = node->get_act ();
if (dont_call == 0)
- this->upcall_functor ().cancellation (*this, node->get_type ());
-
+ this->upcall_functor ().cancellation (*this,
+ node->get_type ());
this->free_node (node);
return 1;
}
@@ -281,11 +289,11 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type,
ACE_TRACE ("ACE_Timer_List_T::cancel");
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
- ACE_Timer_Node_T<TYPE> *curr = this->head_->get_next ();
-
int number_of_cancellations = 0;
- while (curr != this->head_)
+ for (ACE_Timer_Node_T<TYPE> *curr = this->head_->get_next ();
+ curr != this->head_;
+ )
{
if (curr->get_type () == type)
{
@@ -332,5 +340,4 @@ ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
return temp;
}
-
#endif /* ACE_TIMER_LIST_T_C */
diff --git a/ace/Timer_List_T.h b/ace/Timer_List_T.h
index a8963b16d04..9caed213b8a 100644
--- a/ace/Timer_List_T.h
+++ b/ace/Timer_List_T.h
@@ -112,25 +112,27 @@ public:
const void *act,
const ACE_Time_Value &delay,
const ACE_Time_Value &interval = ACE_Time_Value::zero);
- // Schedule <type> that will expire after <delay> amount of time.
- // If it expires then <act> is passed in as the value to the
- // <functor>. If <interval> is != to <ACE_Time_Value::zero> then it
- // is used to reschedule the <type> automatically. This method
- // returns a <timer_id> that uniquely identifies the the <type>
- // entry in an internal list. This <timer_id> can be used to cancel
- // the timer before it expires. The cancellation ensures that
- // <timer_ids> are unique up to values of greater than 2 billion
- // timers. As long as timers don't stay around longer than this
- // there should be no problems with accidentally deleting the wrong
- // timer. Returns -1 on failure (which is guaranteed never to be a
- // valid <timer_id>).
+ // Schedule <type> that will expire after <delay> amount of time,
+ // which is specified in absolute time. If it expires then <act> is
+ // passed in as the value to the <functor>. If <interval> is != to
+ // <ACE_Time_Value::zero> then it is used to reschedule the <type>
+ // automatically, using relative time to the current <gettimeofday>.
+ // This method returns a <timer_id> that uniquely identifies the the
+ // <type> entry in an internal list. This <timer_id> can be used to
+ // cancel the timer before it expires. The cancellation ensures
+ // that <timer_ids> are unique up to values of greater than 2
+ // billion timers. As long as timers don't stay around longer than
+ // this there should be no problems with accidentally deleting the
+ // wrong timer. Returns -1 on failure (which is guaranteed never to
+ // be a valid <timer_id>).
virtual int reset_interval (const long timer_id,
const ACE_Time_Value &interval);
- // Resets the interval of the timer represented by <timer_id> to
- // <interval>. If <interval> is equal to <ACE_Time_Value::zero>,
- // the timer will become a non-rescheduling timer. Returns 1 if
- // successful, 0 if not.
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel (const TYPE &type,
int dont_call_handle_close = 1);
diff --git a/ace/Timer_Queue_T.h b/ace/Timer_Queue_T.h
index ba4a96b9565..f25da9cea9c 100644
--- a/ace/Timer_Queue_T.h
+++ b/ace/Timer_Queue_T.h
@@ -77,7 +77,7 @@ public:
// get the timer interval.
void set_interval (ACE_Time_Value interval);
- // set the timer interval.
+ // Set the timer interval.
ACE_Timer_Node_T<TYPE> *get_prev (void);
// get the previous pointer.
@@ -192,25 +192,27 @@ public:
const void *act,
const ACE_Time_Value &delay,
const ACE_Time_Value &interval = ACE_Time_Value::zero) = 0;
- // Schedule <type> that will expire after <delay> amount of time.
- // If it expires then <act> is passed in as the value to the
- // <functor>. If <interval> is != to <ACE_Time_Value::zero> then it
- // is used to reschedule the <type> automatically. This method
- // returns a <timer_id> that uniquely identifies the the <type>
- // entry in an internal list. This <timer_id> can be used to cancel
- // the timer before it expires. The cancellation ensures that
- // <timer_ids> are unique up to values of greater than 2 billion
- // timers. As long as timers don't stay around longer than this
- // there should be no problems with accidentally deleting the wrong
- // timer. Returns -1 on failure (which is guaranteed never to be a
- // valid <timer_id>).
+ // Schedule <type> that will expire after <delay> amount of time,
+ // which is specified in absolute time. If it expires then <act> is
+ // passed in as the value to the <functor>. If <interval> is != to
+ // <ACE_Time_Value::zero> then it is used to reschedule the <type>
+ // automatically, using relative time to the current <gettimeofday>.
+ // This method returns a <timer_id> that uniquely identifies the the
+ // <type> entry in an internal list. This <timer_id> can be used to
+ // cancel the timer before it expires. The cancellation ensures
+ // that <timer_ids> are unique up to values of greater than 2
+ // billion timers. As long as timers don't stay around longer than
+ // this there should be no problems with accidentally deleting the
+ // wrong timer. Returns -1 on failure (which is guaranteed never to
+ // be a valid <timer_id>).
virtual int reset_interval (const long timer_id,
const ACE_Time_Value &interval) = 0;
- // Resets the interval of the timer represented by <timer_id> to
- // <interval>. If <interval> is equal to <ACE_Time_Value::zero>,
- // the timer will become a non-rescheduling timer. Returns 1 if
- // successful, 0 if not.
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel (const TYPE &type,
int dont_call_handle_close = 1) = 0;
diff --git a/ace/Timer_Wheel_T.cpp b/ace/Timer_Wheel_T.cpp
index d8699bf3ce8..1770e5b0d4e 100644
--- a/ace/Timer_Wheel_T.cpp
+++ b/ace/Timer_Wheel_T.cpp
@@ -163,7 +163,9 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T (FUNCTOR *upcall_f
ACE_Timer_Node_T<TYPE> *[this->wheel_size_]);
// Create the dummy nodes
- for (i = 0; i < this->wheel_size_; i++)
+ for (i = 0;
+ i < this->wheel_size_;
+ i++)
{
ACE_Timer_Node_T<TYPE> *tempnode = this->alloc_node ();
tempnode->set_next (tempnode);
@@ -237,9 +239,9 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const
template <class TYPE, class FUNCTOR, class ACE_LOCK> long
ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
- const void *act,
- const ACE_Time_Value &delay,
- const ACE_Time_Value &interval)
+ const void *act,
+ const ACE_Time_Value &delay,
+ const ACE_Time_Value &interval)
{
ACE_TRACE ("ACE_Timer_Wheel_T::schedule");
ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));
@@ -282,16 +284,19 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (const long timer_id,
// Make sure we are getting a valid <timer_id>, not an error
// returned by <schedule>.
if (timer_id == -1)
- return 0;
+ return -1;
ACE_Timer_Node_T<TYPE> *node =
- (ACE_Timer_Node_T<TYPE> *) timer_id;
+ ACE_reinterpret_cast (ACE_Timer_Node_T<TYPE> *,
+ timer_id);
- // Check to see if the node looks like a true ACE_Timer_Node_T<TYPE>
+ // Check to see if the node looks like a true
+ // ACE_Timer_Node_T<TYPE>.
if (timer_id != node->get_timer_id ())
- return 0;
+ return -1;
node->set_interval (interval);
+ return 0;
}
// Goes through every list in the wheel and if it finds a node with <type>
@@ -308,12 +313,16 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE &type,
size_t i;
// Walk through the wheel
- for (i = 0; i < this->wheel_size_; i++)
+ for (i = 0;
+ i < this->wheel_size_;
+ i++)
{
- ACE_Timer_Node_T<TYPE> *curr = this->wheel_[i]->get_next ();
- // Walk through the list
- while (curr != this->wheel_[i])
+ // Walk through the list.
+ for (ACE_Timer_Node_T<TYPE> *curr =
+ this->wheel_[i]->get_next ();
+ curr != this->wheel_[i];
+ )
{
if (curr->get_type () == type)
{
@@ -379,9 +388,10 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id,
return 0;
ACE_Timer_Node_T<TYPE> *node =
- (ACE_Timer_Node_T<TYPE> *) timer_id;
+ ACE_reinterpret_cast (ACE_Timer_Node_T<TYPE> *,
+ timer_id);
- // Check to see if the node looks like a true ACE_Timer_Node_T<TYPE>
+ // Check to see if the node looks like a true ACE_Timer_Node_T<TYPE>.
if (timer_id == node->get_timer_id ())
{
node->get_next ()->set_prev (node->get_prev ());
@@ -472,7 +482,9 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)
ACE_Time_Value earliest_time;
// Check every entry in the table for the new earliest item
- for (size_t i = 0; i < this->wheel_size_; i++)
+ for (size_t i = 0;
+ i < this->wheel_size_;
+ i++)
{
// Check for an empty entry
if (this->wheel_[i]->get_next () != this->wheel_[i])
@@ -649,7 +661,8 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const ACE_Time_Value &cur_ti
break;
earliest = next_earliest;
- } while (next_earliest != this->wheel_size_);
+ }
+ while (next_earliest != this->wheel_size_);
return number_of_timers_expired;
}
diff --git a/ace/Timer_Wheel_T.h b/ace/Timer_Wheel_T.h
index 02c63650cb0..463f77d4284 100644
--- a/ace/Timer_Wheel_T.h
+++ b/ace/Timer_Wheel_T.h
@@ -117,7 +117,6 @@ public:
// defaults will be used for size and resolution and no preallocation
// (ACE_DEFAULT_TIMER_WHEEL_SIZE, ACE_DEFAULT_TIMER_WHEEL_RESOLUTION)
-
virtual ~ACE_Timer_Wheel_T (void);
// Destructor
@@ -131,20 +130,22 @@ public:
const void *act,
const ACE_Time_Value &delay,
const ACE_Time_Value &interval = ACE_Time_Value::zero);
- // Schedule <type> that will expire after <delay> amount of time.
- // If it expires then <act> is passed in as the value to the
- // <functor>. If <interval> is != to <ACE_Time_Value::zero> then it
- // is used to reschedule the <type> automatically. This method
- // returns a <timer_id> that uniquely identifies the the timer.
- // This <timer_id> can be used to cancel the timer before it expires.
- // Returns -1 on failure.
+ // Schedule <type> that will expire after <delay> amount of time,
+ // which is specified in absolute time. If it expires then <act> is
+ // passed in as the value to the <functor>. If <interval> is != to
+ // <ACE_Time_Value::zero> then it is used to reschedule the <type>
+ // automatically, using relative time to the current <gettimeofday>.
+ // This method returns a <timer_id> that uniquely identifies the the
+ // timer. This <timer_id> can be used to cancel the timer before it
+ // expires. Returns -1 on failure.
virtual int reset_interval (const long timer_id,
const ACE_Time_Value &interval);
- // Resets the interval of the timer represented by <timer_id> to
- // <interval>. If <interval> is equal to <ACE_Time_Value::zero>,
- // the timer will become a non-rescheduling timer. Returns 1 if
- // successful, 0 if not.
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel (const TYPE &type,
int dont_call_handle_close = 1);
diff --git a/ace/TkReactor.cpp b/ace/TkReactor.cpp
index b32a0220333..73ed040335d 100644
--- a/ace/TkReactor.cpp
+++ b/ace/TkReactor.cpp
@@ -356,6 +356,27 @@ ACE_TkReactor::reset_timeout (void)
(ClientData) this);
}
+int
+ACE_TkReactor::reset_timer_interval
+ (const long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_TkReactor::reset_timer_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ int result = ACE_Select_Reactor::timer_queue_->reset_interval
+ (timer_id,
+ interval);
+
+ if (result == -1)
+ return -1;
+ else
+ {
+ this->reset_timeout ();
+ return result;
+ }
+}
+
long
ACE_TkReactor::schedule_timer (ACE_Event_Handler *handler,
const void *arg,
diff --git a/ace/TkReactor.h b/ace/TkReactor.h
index 7290a49d9c3..d3780035005 100644
--- a/ace/TkReactor.h
+++ b/ace/TkReactor.h
@@ -64,10 +64,10 @@ public:
const void *arg,
const ACE_Time_Value &delta_time,
const ACE_Time_Value &interval);
-
+ virtual int reset_timer_interval (const long timer_id,
+ const ACE_Time_Value &interval);
virtual int cancel_timer (ACE_Event_Handler *handler,
int dont_call_handle_close = 1);
-
virtual int cancel_timer (long timer_id,
const void **arg = 0,
int dont_call_handle_close = 1);
@@ -109,6 +109,8 @@ protected:
private:
void reset_timeout (void);
+ // This method ensures there's a Tk timeout for the first timeout in
+ // the Reactor's Timer_Queue.
// = Integrate with the X callback function mechanism.
static void TimerCallbackProc (ClientData cd);
diff --git a/ace/WFMO_Reactor.h b/ace/WFMO_Reactor.h
index 4cbb941312e..e73e54e0121 100644
--- a/ace/WFMO_Reactor.h
+++ b/ace/WFMO_Reactor.h
@@ -766,18 +766,27 @@ public:
const ACE_Time_Value &delta,
const ACE_Time_Value &interval = ACE_Time_Value::zero);
// Schedule an <event_handler> that will expire after <delay> amount
- // of time. If it expires then <arg> is passed in as the value to
- // the <event_handler>'s <handle_timeout> callback method. If
- // <interval> is != to <ACE_Time_Value::zero> then it is used to
- // reschedule the <event_handler> automatically. This method
- // returns a <timer_id> that uniquely identifies the <event_handler>
- // in an internal list. This <timer_id> can be used to cancel an
- // <event_handler> before it expires. The cancellation ensures that
- // <timer_ids> are unique up to values of greater than 2 billion
- // timers. As long as timers don't stay around longer than this
- // there should be no problems with accidentally deleting the wrong
- // timer. Returns -1 on failure (which is guaranteed never to be a
- // valid <timer_id>.
+ // of time, which is specified using relative time to the current
+ // <gettimeofday>. If it expires then <arg> is passed in as the
+ // value to the <event_handler>'s <handle_timeout> callback method.
+ // If <interval> is != to <ACE_Time_Value::zero> then it is used to
+ // reschedule the <event_handler> automatically, which is also
+ // specified using relative time. This method returns a <timer_id>
+ // that uniquely identifies the <event_handler> in an internal list.
+ // This <timer_id> can be used to cancel an <event_handler> before
+ // it expires. The cancellation ensures that <timer_ids> are unique
+ // up to values of greater than 2 billion timers. As long as timers
+ // don't stay around longer than this there should be no problems
+ // with accidentally deleting the wrong timer. Returns -1 on
+ // failure (which is guaranteed never to be a valid <timer_id>.
+
+ virtual int reset_timer_interval (const long timer_id,
+ const ACE_Time_Value &interval);
+ // Resets the interval of the timer represented by <timer_id> to
+ // <interval>, which is specified in relative time to the current
+ // <gettimeofday>. If <interval> is equal to
+ // <ACE_Time_Value::zero>, the timer will become a non-rescheduling
+ // timer. Returns 0 if successful, -1 if not.
virtual int cancel_timer (ACE_Event_Handler *event_handler,
int dont_call_handle_close = 1);
diff --git a/ace/WFMO_Reactor.i b/ace/WFMO_Reactor.i
index 3a4215119be..d2d71d92ae0 100644
--- a/ace/WFMO_Reactor.i
+++ b/ace/WFMO_Reactor.i
@@ -432,6 +432,24 @@ ACE_WFMO_Reactor_Handler_Repository::unbind (ACE_HANDLE handle,
}
ACE_INLINE long
+ACE_WFMO_Reactor::reset_timer_interval
+ (const long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_WFMO_Reactor::reset_timer_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ long result = this->timer_queue_->reset_interval
+ (timer_id,
+ interval);
+
+ // Wakeup the owner thread so that it gets the latest timer values
+ this->notify ();
+
+ return result;
+}
+
+ACE_INLINE long
ACE_WFMO_Reactor::schedule_timer (ACE_Event_Handler *handler,
const void *arg,
const ACE_Time_Value &delta_time,
@@ -440,7 +458,10 @@ ACE_WFMO_Reactor::schedule_timer (ACE_Event_Handler *handler,
ACE_TRACE ("ACE_WFMO_Reactor::schedule_timer");
long result = this->timer_queue_->schedule
- (handler, arg, timer_queue_->gettimeofday () + delta_time, interval);
+ (handler,
+ arg,
+ timer_queue_->gettimeofday () + delta_time,
+ interval);
// Wakeup the owner thread so that it gets the latest timer values
this->notify ();
diff --git a/ace/XtReactor.cpp b/ace/XtReactor.cpp
index 8acce2bdf4a..a66f5196947 100644
--- a/ace/XtReactor.cpp
+++ b/ace/XtReactor.cpp
@@ -371,6 +371,27 @@ ACE_XtReactor::reset_timeout (void)
(XtPointer) this);
}
+int
+ACE_XtReactor::reset_timer_interval
+ (const long timer_id,
+ const ACE_Time_Value &interval)
+{
+ ACE_TRACE ("ACE_XtReactor::reset_timer_interval");
+ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
+
+ int result = ACE_Select_Reactor::timer_queue_->reset_interval
+ (timer_id,
+ interval);
+
+ if (result == -1)
+ return -1;
+ else
+ {
+ this->reset_timeout ();
+ return result;
+ }
+}
+
long
ACE_XtReactor::schedule_timer (ACE_Event_Handler *handler,
const void *arg,
diff --git a/ace/XtReactor.h b/ace/XtReactor.h
index 2895626357c..cf2ad2338e8 100644
--- a/ace/XtReactor.h
+++ b/ace/XtReactor.h
@@ -68,7 +68,8 @@ public:
const void *arg,
const ACE_Time_Value &delta_time,
const ACE_Time_Value &interval);
-
+ virtual int reset_timer_interval (const long timer_id,
+ const ACE_Time_Value &interval);
virtual int cancel_timer (ACE_Event_Handler *handler,
int dont_call_handle_close = 1);
@@ -114,6 +115,8 @@ protected:
private:
void reset_timeout (void);
+ // This method ensures there's an Xt timeout for the first timeout
+ // in the Reactor's Timer_Queue.
// = Integrate with the X callback function mechanism.
static void TimerCallbackProc (XtPointer closure, XtIntervalId *id);