#include <Cached_Connect_Strategy_T.h>
Inheritance diagram for ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >:


Public Types | |
| typedef ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR >  | REFCOUNTED_HASH_RECYCLABLE_ADDRESS | 
| typedef ACE_Hash_Cache_Map_Manager< REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash< REFCOUNTED_HASH_RECYCLABLE_ADDRESS >, ACE_Equal_To< REFCOUNTED_HASH_RECYCLABLE_ADDRESS >, CACHING_STRATEGY, ATTRIBUTES >  | CONNECTION_CACHE | 
| typedef ACE_TYPENAME CONNECTION_CACHE::CACHE_ENTRY | CONNECTION_CACHE_ENTRY | 
| typedef ACE_TYPENAME CONNECTION_CACHE::key_type | KEY | 
| typedef ACE_TYPENAME CONNECTION_CACHE::mapped_type | VALUE | 
| typedef ACE_Recyclable_Handler_Cleanup_Strategy< REFCOUNTED_HASH_RECYCLABLE_ADDRESS, ACE_Pair< SVC_HANDLER *, ATTRIBUTES >, ACE_Hash_Map_Manager_Ex< REFCOUNTED_HASH_RECYCLABLE_ADDRESS, ACE_Pair< SVC_HANDLER *, ATTRIBUTES >, ACE_Hash< REFCOUNTED_HASH_RECYCLABLE_ADDRESS >, ACE_Equal_To< REFCOUNTED_HASH_RECYCLABLE_ADDRESS >, MUTEX > >  | CLEANUP_STRATEGY | 
| typedef ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >  | CCSBASE | 
Public Member Functions | |
| ACE_Cached_Connect_Strategy_Ex (CACHING_STRATEGY &caching_s, ACE_Creation_Strategy< SVC_HANDLER > *cre_s=0, ACE_Concurrency_Strategy< SVC_HANDLER > *con_s=0, ACE_Recycling_Strategy< SVC_HANDLER > *rec_s=0, MUTEX *lock=0, int delete_lock=0) | |
| Constructor.   | |
| virtual | ~ACE_Cached_Connect_Strategy_Ex (void) | 
| Destructor.   | |
| virtual int | purge_connections (void) | 
| Explicit purging of connection entries from the connection cache.   | |
| virtual int | mark_as_closed_i (const void *recycling_act) | 
| void | cleanup (void) | 
| CACHING_STRATEGY & | caching_strategy (void) | 
Protected Member Functions | |
| int | find (ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR > &search_addr, ACE_Hash_Map_Entry< ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR >, ACE_Pair< SVC_HANDLER *, ATTRIBUTES > > *&entry) | 
| Find an idle handle.   | |
| virtual int | purge_i (const void *recycling_act) | 
| Remove from cache (non-locking version).   | |
| virtual int | cache_i (const void *recycling_act) | 
| Add to cache (non-locking version).   | |
| virtual int | recycle_state_i (const void *recycling_act, ACE_Recyclable_State new_state) | 
| Get/Set  (non-locking version).   | |
| virtual ACE_Recyclable_State | recycle_state_i (const void *recycling_act) const | 
| Get  (non-locking version).   | |
| virtual int | cleanup_hint_i (const void *recycling_act, void **act_holder) | 
| Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>.   | |
| int | 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 >, ACE_Pair< SVC_HANDLER *, ATTRIBUTES > > *&entry, int &found) | 
| virtual int | 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 >, ACE_Pair< SVC_HANDLER *, ATTRIBUTES > > *&entry, int &found) | 
| virtual int | 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) | 
| virtual int | cached_connect (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) | 
Protected Attributes | |
| CONNECTION_CACHE | connection_cache_ | 
| Table that maintains the cache of connected s.   | |
is intended to be used as a plug-in connection strategy for ACE_Strategy_Connector. It's added value is re-use of established connections and tweaking the role of the cache as per the caching strategy.
Definition at line 48 of file Cached_Connect_Strategy_T.h.
      
  | 
  |||||
| 
 
 Definition at line 102 of file Cached_Connect_Strategy_T.h.  | 
  
      
  | 
  |||||
| 
 
 Definition at line 99 of file Cached_Connect_Strategy_T.h.  | 
  
      
  | 
  |||||
| 
 
 Definition at line 87 of file Cached_Connect_Strategy_T.h.  | 
  
      
  | 
  |||||
      
  | 
  |||||
| 
 
 Definition at line 89 of file Cached_Connect_Strategy_T.h.  | 
  
      
  | 
  |||||
| 
 
 Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Reimplemented in ACE_Bounded_Cached_Connect_Strategy< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >. Definition at line 80 of file Cached_Connect_Strategy_T.h.  | 
  
      
  | 
  |||||
| 
 
 Definition at line 90 of file Cached_Connect_Strategy_T.h.  | 
  
      
  | 
  ||||||||||||||||||||||||||||||||
| 
 Constructor. 
  | 
  
      
  | 
  ||||||||||
| 
 Destructor. 
 Definition at line 42 of file Cached_Connect_Strategy_T.cpp. References ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::cleanup(). 
 00043 {
00044   cleanup ();
00045 }
 | 
  
      
  | 
  ||||||||||
| 
 Add to cache (non-locking version). 
 Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 373 of file Cached_Connect_Strategy_T.cpp. References ACE_RECYCLABLE_IDLE_AND_PURGABLE, and ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::CONNECTION_CACHE_ENTRY. 
 00374 {
00375   // The wonders and perils of ACT
00376   CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00377 
00378   // Mark the <svc_handler> in the cache as not being <in_use>.
00379   // Therefore recyclable is IDLE.
00380   entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
00381 
00382   return 0;
00383 }
 | 
  
      
  | 
  ||||||||||||||||||||||||||||||||||||
| 
 Connection of the svc_handler with the remote host. This method also encapsulates the connection done with auto_purging under the hood. If the connect failed due to the process running out of file descriptors then, auto_purging of some connections are done from the CONNECTION_CACHE. This frees the descriptors which get used in the connect process and hence the connect operation can succeed.  | 
  
      
  | 
  ||||||||||
| 
 
 Definition at line 467 of file Cached_Connect_Strategy_T.cpp. References ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::connection_cache_. 
 00468 {
00469   return this->connection_cache_.caching_strategy ();
00470 }
 | 
  
      
  | 
  ||||||||||||||||||||||||||||||||||||||||||||
| 
 
  | 
  
      
  | 
  ||||||||||
| 
 Since g++ version < 2.8 arent happy with templates, this special method had to be devised to avoid memory leaks and perform cleanup of the . Definition at line 526 of file Cached_Connect_Strategy_T.cpp. References ACE_GUARD, ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::connection_cache_, ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::CONNECTION_CACHE_ENTRY, and ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::purge_i(). Referenced by ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::~ACE_Cached_Connect_Strategy_Ex(). 
 00527 {
00528   // Excluded other threads from changing the cache while we cleanup
00529   ACE_GUARD (MUTEX, ace_mon, *this->lock_);
00530 
00531   // Close down all cached service handlers.
00532   ACE_TYPENAME CONNECTION_CACHE::ITERATOR iter =
00533     this->connection_cache_.begin ();
00534   while (iter != this->connection_cache_.end ())
00535     {
00536       if ((*iter).second () != 0)
00537         {
00538           // save entry for future use
00539           CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *)
00540             (*iter).second ()->recycling_act ();
00541 
00542           // close handler
00543           (*iter).second ()->recycler (0, 0);
00544           (*iter).second ()->close ();
00545 
00546           // remember next iter
00547           ACE_TYPENAME CONNECTION_CACHE::ITERATOR next_iter = iter;
00548           ++next_iter;
00549 
00550           // purge the item from the hash
00551           this->purge_i (entry);
00552 
00553           // assign next iter
00554           iter  = next_iter;
00555         }
00556      else
00557        ++iter;
00558     }
00559 }
 | 
  
      
  | 
  ||||||||||||||||
| 
 Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>. 
 Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 433 of file Cached_Connect_Strategy_T.cpp. References ACE_RECYCLABLE_CLOSED, ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::CONNECTION_CACHE_ENTRY, and ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::purge_i(). 
 00435 {
00436   // Reset the <*act_holder> in the confines and protection of the
00437   // lock.
00438   if (act_holder)
00439     *act_holder = 0;
00440 
00441   // The wonders and perils of ACT
00442   CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00443 
00444   // Decrement the refcount on the <svc_handler>.
00445   int refcount = entry->ext_id_.decrement ();
00446 
00447   // If the svc_handler state is closed and the refcount == 0, call
00448   // close() on svc_handler.
00449   if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED &&
00450       refcount == 0)
00451     {
00452       entry->int_id_.first ()->recycler (0, 0);
00453       entry->int_id_.first ()->close ();
00454       this->purge_i (entry);
00455     }
00456 
00457   return 0;
00458 }
 | 
  
      
  | 
  ||||||||||||||||||||||||||||||||||||||||
| 
 
 Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >.  | 
  
      
  | 
  ||||||||||||||||
| 
 Find an idle handle. 
  | 
  
      
  | 
  ||||||||||||||||||||||||||||||||||||||||||||
| 
 
 Reimplemented in ACE_Bounded_Cached_Connect_Strategy< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >.  | 
  
      
  | 
  ||||||||||
| 
 Mark as closed (non-locking version). This is used during the cleanup of the connections purged. Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 421 of file Cached_Connect_Strategy_T.cpp. References ACE_RECYCLABLE_CLOSED, and ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::CONNECTION_CACHE_ENTRY. 
 00422 {
00423   // The wonders and perils of ACT
00424   CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00425 
00426   // Mark the <svc_handler> in the cache as CLOSED.
00427   entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED);
00428 
00429   return 0;
00430 }
 | 
  
      
  | 
  ||||||||||
| 
 Explicit purging of connection entries from the connection cache. 
 Definition at line 461 of file Cached_Connect_Strategy_T.cpp. References ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::connection_cache_. 
 00462 {
00463   return this->connection_cache_.purge ();
00464 }
 | 
  
      
  | 
  ||||||||||
| 
 Remove from cache (non-locking version). 
 Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 411 of file Cached_Connect_Strategy_T.cpp. References ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::connection_cache_, ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::CONNECTION_CACHE_ENTRY, and ACE_Hash_Cache_Map_Manager< KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES >::unbind(). Referenced by ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::cleanup(), and ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::cleanup_hint_i(). 
 00412 {
00413   // The wonders and perils of ACT
00414   CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00415 
00416   return this->connection_cache_.unbind (entry);
00417 }
 | 
  
      
  | 
  ||||||||||
| 
 Get (non-locking version). 
 Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 400 of file Cached_Connect_Strategy_T.cpp. References ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::CONNECTION_CACHE_ENTRY. 
 00401 {
00402   // The wonders and perils of ACT
00403   CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00404 
00405   // Mark the <svc_handler> in the cache as not being <in_use>.
00406   // Therefore recyclable is IDLE.
00407   return entry->ext_id_.recycle_state ();
00408 }
 | 
  
      
  | 
  ||||||||||||||||
| 
 Get/Set (non-locking version). 
 Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 386 of file Cached_Connect_Strategy_T.cpp. References ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER,, CACHING_STRATEGY, ATTRIBUTES, MUTEX >::CONNECTION_CACHE_ENTRY. 
 00388 {
00389   // The wonders and perils of ACT
00390   CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00391 
00392   // Mark the <svc_handler> in the cache as not being <in_use>.
00393   // Therefore recyclable is IDLE.
00394   entry->ext_id_.recycle_state (new_state);
00395 
00396   return 0;
00397 }
 | 
  
      
  | 
  |||||
 
1.3.6