diff options
author | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-09-25 15:59:37 +0000 |
---|---|---|
committer | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-09-25 15:59:37 +0000 |
commit | 1aa2f3ed7662fa101486b9ca7a1c15133b6b57f6 (patch) | |
tree | 20caac6b002bdfaaf5a2517fa97a65d3121db7a4 /ACE/ace/Timer_Hash_T.cpp | |
parent | 64138603687e921273ef37a3e7b964a3367bf005 (diff) | |
download | ATCD-1aa2f3ed7662fa101486b9ca7a1c15133b6b57f6.tar.gz |
ChangeLogTag: Tue Sep 25 15:55:21 UTC 2007 Vladimir Zykov <vladimir.zykov@prismtech.com>
Diffstat (limited to 'ACE/ace/Timer_Hash_T.cpp')
-rw-r--r-- | ACE/ace/Timer_Hash_T.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/ACE/ace/Timer_Hash_T.cpp b/ACE/ace/Timer_Hash_T.cpp index eab4b01e2f0..7d3edb5a6c1 100644 --- a/ACE/ace/Timer_Hash_T.cpp +++ b/ACE/ace/Timer_Hash_T.cpp @@ -20,6 +20,9 @@ ACE_RCSID(ace, template <class TYPE> struct Hash_Token { + Hash_Token (void) + {} + Hash_Token (const void *act, size_t pos, long orig_id, @@ -30,10 +33,25 @@ struct Hash_Token type_ (type) {} + ~Hash_Token (void) + {} + + Hash_Token<TYPE> *get_next (void) + { + return this->next_; + } + + void set_next (Hash_Token<TYPE> *next) + { + this->next_ = next; + } + const void *act_; size_t pos_; long orig_id_; TYPE type_; + /// Pointer to next token. + Hash_Token<TYPE> *next_; }; // Default constructor @@ -151,8 +169,6 @@ ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>::deletion ( event_handler, h->act_); - delete h; - return result; } @@ -261,6 +277,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T ( #if defined (ACE_WIN64) , pointer_base_ (0) #endif /* ACE_WIN64 */ + , token_list_ () { ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T"); @@ -296,6 +313,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T ( #if defined (ACE_WIN64) , pointer_base_ (0) #endif /* ACE_WIN64 */ + , token_list_ () { ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T"); @@ -402,6 +420,10 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule ( expired->get_interval ()); ACE_ASSERT (h->orig_id_ != -1); + // Since schedule above will allocated new node + // then schedule <expired> for deletion. + this->free_node (expired); + #if 0 ACE_DEBUG ((LM_DEBUG, "Hash::reschedule() resets %d in slot %d where it's id is %d and token is %x\n", expired->get_timer_value ().msec (), @@ -443,6 +465,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule_i ( 0, type), -1); + this->token_list_.add (h); h->orig_id_ = this->table_[position]->schedule (type, @@ -580,8 +603,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (long timer_id, if (act != 0) *act = h->act_; - delete h; - --this->size_; } @@ -639,8 +660,6 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type, ACE_ASSERT (result == 1); ACE_UNUSED_ARG (result); - delete timer_ids[i]; - --this->size_; } @@ -796,6 +815,10 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire (const ACE_Time_Value this->reschedule (expired); reclaim = false; } + else + { + this->free_node (expired); + } ACE_Timer_Node_Dispatch_Info_T<TYPE> info; @@ -813,10 +836,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::expire (const ACE_Time_Value this->postinvoke (info, cur_time, upcall_act); if (reclaim) - { - --this->size_; - delete h; - } + --this->size_; ++number_of_timers_expired; } |