diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-20 01:12:26 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-20 01:12:26 +0000 |
commit | daedcd54c2d99ba783d0684026bd4a8b058889c4 (patch) | |
tree | 5bfb060afaaed3b9e66ba57fac2818051d8e8c17 /ace/Strategies_T.cpp | |
parent | 7e9e1f8831e2535c14f0a029bce005e823ca8349 (diff) | |
download | ATCD-daedcd54c2d99ba783d0684026bd4a8b058889c4.tar.gz |
ChangeLogTag:Mon Jul 19 19:46:50 1999 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'ace/Strategies_T.cpp')
-rw-r--r-- | ace/Strategies_T.cpp | 207 |
1 files changed, 115 insertions, 92 deletions
diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp index 20db86e1f05..f2d720bff58 100644 --- a/ace/Strategies_T.cpp +++ b/ace/Strategies_T.cpp @@ -228,9 +228,9 @@ ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handler template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy - (const ACE_PEER_ACCEPTOR_ADDR &local_addr, - int restart, - ACE_Reactor *reactor) +(const ACE_PEER_ACCEPTOR_ADDR &local_addr, + int restart, + ACE_Reactor *reactor) : reactor_ (reactor) { ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy"); @@ -243,7 +243,7 @@ ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Accept_Strategy template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler - (SVC_HANDLER *svc_handler) +(SVC_HANDLER *svc_handler) { ACE_TRACE ("ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler"); @@ -271,13 +271,13 @@ ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) { ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler"); @@ -292,14 +292,14 @@ ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1> int ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler - (SVC_HANDLER *&sh, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) +(SVC_HANDLER *&sh, + SVC_HANDLER *&sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) { ACE_TRACE ("ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::connect_svc_handler"); @@ -368,19 +368,19 @@ ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handle template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::ACE_Cached_Connect_Strategy - (ACE_Creation_Strategy<SVC_HANDLER> *cre_s, - ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, - ACE_Recycling_Strategy<SVC_HANDLER> *rec_s, - MUTEX *lock, - int delete_lock) - : lock_ (lock), - delete_lock_ (delete_lock), - creation_strategy_ (0), - delete_creation_strategy_ (0), - concurrency_strategy_ (0), - delete_concurrency_strategy_ (0), - recycling_strategy_ (0), - delete_recycling_strategy_ (0) +(ACE_Creation_Strategy<SVC_HANDLER> *cre_s, + ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, + ACE_Recycling_Strategy<SVC_HANDLER> *rec_s, + MUTEX *lock, + int delete_lock) + : lock_ (lock), + delete_lock_ (delete_lock), + creation_strategy_ (0), + delete_creation_strategy_ (0), + concurrency_strategy_ (0), + delete_concurrency_strategy_ (0), + recycling_strategy_ (0), + delete_recycling_strategy_ (0) { // Create a new lock if necessary. if (this->lock_ == 0) @@ -431,9 +431,9 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::~ACE_Cach template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::open - (ACE_Creation_Strategy<SVC_HANDLER> *cre_s, - ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, - ACE_Recycling_Strategy<SVC_HANDLER> *rec_s) +(ACE_Creation_Strategy<SVC_HANDLER> *cre_s, + ACE_Concurrency_Strategy<SVC_HANDLER> *con_s, + ACE_Recycling_Strategy<SVC_HANDLER> *rec_s) { // Initialize the creation strategy. @@ -501,15 +501,15 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::open template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hint_i - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, SVC_HANDLER *> *&entry, - int &found) +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, SVC_HANDLER *> *&entry, + int &found) { ACE_UNUSED_ARG (remote_addr); ACE_UNUSED_ARG (timeout); @@ -524,7 +524,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hin CONNECTION_MAP_ENTRY *possible_entry = (CONNECTION_MAP_ENTRY *) sh->recycling_act (); // Check to see if the hint svc_handler has been closed down - if (possible_entry->ext_id_.state () == ACE_RECYCLABLE_CLOSED) + if (possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED) { // If close, decrement refcount if (possible_entry->ext_id_.decrement () == 0) @@ -544,8 +544,8 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hin // If hint is not closed, see if it is connected to the correct // address and is recyclable - else if ((possible_entry->ext_id_.state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || - possible_entry->ext_id_.state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) && + else if ((possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE || + possible_entry->ext_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) && possible_entry->ext_id_.subject () == remote_addr) { // Hint successful @@ -576,15 +576,15 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::check_hin template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_create_svc_handler_i - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, SVC_HANDLER *> *&entry, - int &found) +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, SVC_HANDLER *> *&entry, + int &found) { // Explicit type conversion REFCOUNTED_HASH_RECYCLABLE_ADDRESS search_addr (remote_addr); @@ -650,13 +650,13 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_c template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) { int found = 0; @@ -700,14 +700,14 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_s template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler - (SVC_HANDLER *&sh, - SVC_HANDLER *&sh_copy, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms) +(SVC_HANDLER *&sh, + SVC_HANDLER *&sh_copy, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms) { int found = 0; @@ -753,14 +753,14 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_s template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_svc_handler_i - (SVC_HANDLER *&sh, - const ACE_PEER_CONNECTOR_ADDR &remote_addr, - ACE_Time_Value *timeout, - const ACE_PEER_CONNECTOR_ADDR &local_addr, - int reuse_addr, - int flags, - int perms, - int& found) +(SVC_HANDLER *&sh, + const ACE_PEER_CONNECTOR_ADDR &remote_addr, + ACE_Time_Value *timeout, + const ACE_PEER_CONNECTOR_ADDR &local_addr, + int reuse_addr, + int flags, + int perms, + int& found) { CONNECTION_MAP_ENTRY *entry = 0; @@ -798,7 +798,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::connect_s // For all successful cases: mark the <svc_handler> in the cache // as being <in_use>. Therefore recyclable is BUSY. - entry->ext_id_.state (ACE_RECYCLABLE_BUSY); + entry->ext_id_.recycle_state (ACE_RECYCLABLE_BUSY); // And increment the refcount entry->ext_id_.increment (); @@ -825,38 +825,61 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache_i ( // Mark the <svc_handler> in the cache as not being <in_use>. // Therefore recyclable is IDLE. - entry->ext_id_.state (ACE_RECYCLABLE_IDLE_AND_PURGABLE); + entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE); return 0; } template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int -ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::state (const void *recycling_act, - ACE_Recyclable_State new_state) +ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act, + ACE_Recyclable_State new_state) { // Synchronization is required here as the setting of the recyclable // state must be done atomically with respect to other threads that // are querying the cache. ACE_GUARD_RETURN (MUTEX, ace_mon, *this->lock_, -1); - return this->state_i (recycling_act, - new_state); + return this->recycle_state_i (recycling_act, + new_state); } template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int -ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::state_i (const void *recycling_act, - ACE_Recyclable_State new_state) +ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act, + ACE_Recyclable_State new_state) { // The wonders and perils of ACT CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act; // Mark the <svc_handler> in the cache as not being <in_use>. // Therefore recyclable is IDLE. - entry->ext_id_.state (new_state); + entry->ext_id_.recycle_state (new_state); return 0; } +template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State +ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state (const void *recycling_act) const +{ + // Const cast. + SELF *fake_this = ACE_const_cast (SELF *, this); + + // Synchronization is required here. + ACE_GUARD_RETURN (MUTEX, ace_mon, *fake_this->lock_, ACE_RECYCLABLE_UNKNOWN); + + return this->recycle_state_i (recycling_act); +} + +template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> ACE_Recyclable_State +ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::recycle_state_i (const void *recycling_act) const +{ + // The wonders and perils of ACT + CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act; + + // Mark the <svc_handler> in the cache as not being <in_use>. + // Therefore recyclable is IDLE. + return entry->ext_id_.recycle_state (); +} + template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> int ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::purge (const void *recycling_act) { @@ -893,7 +916,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::mark_as_c CONNECTION_MAP_ENTRY *entry = (CONNECTION_MAP_ENTRY *) recycling_act; // Mark the <svc_handler> in the cache as CLOSED. - entry->ext_id_.state (ACE_RECYCLABLE_CLOSED); + entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED); return 0; } @@ -919,7 +942,7 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cleanup_h // If the svc_handler state is closed and the refcount == 0, call // close() on svc_handler. - if (entry->ext_id_.state () == ACE_RECYCLABLE_CLOSED && + if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED && refcount == 0) { entry->int_id_->recycler (0, 0); @@ -972,8 +995,8 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find (ACE { REFCOUNTED_HASH_RECYCLABLE_ADDRESS &addr = (*iterator).ext_id_; - if (addr.state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE && - addr.state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) + if (addr.recycle_state () != ACE_RECYCLABLE_IDLE_AND_PURGABLE && + addr.recycle_state () != ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE) continue; if (addr.subject () != search_addr.subject ()) |