#include <Cached_Connect_Strategy_T.h>
Inheritance diagram for ACE_Cached_Connect_Strategy_Ex:


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 Methods | |
| 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. More... | |
| virtual | ~ACE_Cached_Connect_Strategy_Ex (void) |
| Destructor. More... | |
| virtual int | purge_connections (void) |
| Explicit purging of connection entries from the connection cache. More... | |
| virtual int | mark_as_closed_i (const void *recycling_act) |
| Mark as closed (non-locking version). This is used during the cleanup of the connections purged. More... | |
| void | cleanup (void) |
| CACHING_STRATEGY & | caching_strategy (void) |
Protected Methods | |
| 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. More... | |
| virtual int | purge_i (const void *recycling_act) |
| Remove from cache (non-locking version). More... | |
| virtual int | cache_i (const void *recycling_act) |
| Add to cache (non-locking version). More... | |
| virtual int | recycle_state_i (const void *recycling_act, ACE_Recyclable_State new_state) |
| Get/Set <recycle_state> (non-locking version). More... | |
| virtual ACE_Recyclable_State | recycle_state_i (const void *recycling_act) const |
| virtual int | cleanup_hint_i (const void *recycling_act, void **act_holder) |
| Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>. More... | |
| 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 <SVC_HANDLER>s. More... | |
<Cached_Connect_Strategy> 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 47 of file Cached_Connect_Strategy_T.h.
|
|||||
|
Definition at line 101 of file Cached_Connect_Strategy_T.h. |
|
|||||
|
Definition at line 98 of file Cached_Connect_Strategy_T.h. |
|
|||||
|
Definition at line 86 of file Cached_Connect_Strategy_T.h. |
|
|||||
|
Definition at line 87 of file Cached_Connect_Strategy_T.h. Referenced by cache_i, cleanup, cleanup_hint_i, mark_as_closed_i, purge_i, and recycle_state_i. |
|
|||||
|
Definition at line 88 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. Definition at line 79 of file Cached_Connect_Strategy_T.h. |
|
|||||
|
Definition at line 89 of file Cached_Connect_Strategy_T.h. |
|
||||||||||||||||||||||||||||||||
|
Constructor.
|
|
||||||||||
|
Destructor.
Definition at line 44 of file Cached_Connect_Strategy_T.cpp. References cleanup.
00045 {
00046 cleanup ();
00047 }
|
|
||||||||||
|
Add to cache (non-locking version).
Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 377 of file Cached_Connect_Strategy_T.cpp. References ACE_RECYCLABLE_IDLE_AND_PURGABLE, and CONNECTION_CACHE_ENTRY.
00378 {
00379 // The wonders and perils of ACT
00380 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00381
00382 // Mark the <svc_handler> in the cache as not being <in_use>.
00383 // Therefore recyclable is IDLE.
00384 entry->ext_id_.recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
00385
00386 return 0;
00387 }
|
|
||||||||||||||||||||||||||||||||||||
|
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 471 of file Cached_Connect_Strategy_T.cpp. References connection_cache_.
00472 {
00473 return this->connection_cache_.caching_strategy ();
00474 }
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||
|
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 <connection_cache_>. Definition at line 530 of file Cached_Connect_Strategy_T.cpp. References ACE_GUARD, ACE_TYPENAME, connection_cache_, CONNECTION_CACHE_ENTRY, ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >::CONNECTION_MAP_ITERATOR, and purge_i. Referenced by ~ACE_Cached_Connect_Strategy_Ex.
00531 {
00532 // Excluded other threads from changing the cache while we cleanup
00533 ACE_GUARD (MUTEX, ace_mon, *this->lock_);
00534 // Close down all cached service handlers.
00535 #if defined (ACE_HAS_BROKEN_EXTENDED_TEMPLATES)
00536
00537 typedef ACE_Hash_Map_Iterator_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
00538 ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,
00539 ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
00540 ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
00541 ACE_Null_Mutex>
00542 CONNECTION_MAP_ITERATOR;
00543
00544 // CONNECTION_MAP_ITERATOR end = this->connection_cache_.map ().end ();
00545 CONNECTION_MAP_ITERATOR iter = this->connection_cache_.map ().begin ();
00546
00547
00548 while (iter != this->connection_cache_.map ().end ())
00549 {
00550 if ((*iter).int_id_.first () != 0)
00551 {
00552 // save entry for future use
00553 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *)
00554 (*iter).int_id_.first ()->recycling_act ();
00555
00556 // close handler
00557 (*iter).int_id_.first ()->recycler (0, 0);
00558 (*iter).int_id_.first ()->close ();
00559
00560 // remember next iter
00561 CONNECTION_MAP_ITERATOR next_iter = iter;
00562 ++next_iter;
00563
00564 // purge the item from the hash
00565 this->purge_i (entry);
00566
00567 // assign next iter
00568 iter = next_iter;
00569 }
00570 else
00571 ++iter;
00572 }
00573 #else /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */
00574 ACE_TYPENAME CONNECTION_CACHE::ITERATOR iter =
00575 this->connection_cache_.begin ();
00576 while (iter != this->connection_cache_.end ())
00577 {
00578 if ((*iter).second () != 0)
00579 {
00580 // save entry for future use
00581 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *)
00582 (*iter).second ()->recycling_act ();
00583
00584 // close handler
00585 (*iter).second ()->recycler (0, 0);
00586 (*iter).second ()->close ();
00587
00588 // remember next iter
00589 ACE_TYPENAME CONNECTION_CACHE::ITERATOR next_iter = iter;
00590 ++next_iter;
00591
00592 // purge the item from the hash
00593 this->purge_i (entry);
00594
00595 // assign next iter
00596 iter = next_iter;
00597 }
00598 else
00599 ++iter;
00600 }
00601 #endif /* ACE_HAS_BROKEN_EXTENDED_TEMPLATES */
00602
00603 }
|
|
||||||||||||||||
|
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 437 of file Cached_Connect_Strategy_T.cpp. References ACE_RECYCLABLE_CLOSED, CONNECTION_CACHE_ENTRY, and purge_i.
00439 {
00440 // Reset the <*act_holder> in the confines and protection of the
00441 // lock.
00442 if (act_holder)
00443 *act_holder = 0;
00444
00445 // The wonders and perils of ACT
00446 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00447
00448 // Decrement the refcount on the <svc_handler>.
00449 int refcount = entry->ext_id_.decrement ();
00450
00451 // If the svc_handler state is closed and the refcount == 0, call
00452 // close() on svc_handler.
00453 if (entry->ext_id_.recycle_state () == ACE_RECYCLABLE_CLOSED &&
00454 refcount == 0)
00455 {
00456 entry->int_id_.first ()->recycler (0, 0);
00457 entry->int_id_.first ()->close ();
00458 this->purge_i (entry);
00459 }
00460
00461 return 0;
00462 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. |
|
||||||||||||||||
|
Find an idle handle.
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Reimplemented in ACE_Bounded_Cached_Connect_Strategy. |
|
||||||||||
|
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 425 of file Cached_Connect_Strategy_T.cpp. References ACE_RECYCLABLE_CLOSED, and CONNECTION_CACHE_ENTRY.
00426 {
00427 // The wonders and perils of ACT
00428 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00429
00430 // Mark the <svc_handler> in the cache as CLOSED.
00431 entry->ext_id_.recycle_state (ACE_RECYCLABLE_CLOSED);
00432
00433 return 0;
00434 }
|
|
||||||||||
|
Explicit purging of connection entries from the connection cache.
Definition at line 465 of file Cached_Connect_Strategy_T.cpp. References connection_cache_.
00466 {
00467 return this->connection_cache_.purge ();
00468 }
|
|
||||||||||
|
Remove from cache (non-locking version).
Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 415 of file Cached_Connect_Strategy_T.cpp. References connection_cache_, CONNECTION_CACHE_ENTRY, and 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 >::unbind. Referenced by cleanup, and cleanup_hint_i.
00416 {
00417 // The wonders and perils of ACT
00418 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00419
00420 return this->connection_cache_.unbind (entry);
00421 }
|
|
||||||||||
|
Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 404 of file Cached_Connect_Strategy_T.cpp. References CONNECTION_CACHE_ENTRY.
00405 {
00406 // The wonders and perils of ACT
00407 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00408
00409 // Mark the <svc_handler> in the cache as not being <in_use>.
00410 // Therefore recyclable is IDLE.
00411 return entry->ext_id_.recycle_state ();
00412 }
|
|
||||||||||||||||
|
Get/Set <recycle_state> (non-locking version).
Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >. Definition at line 390 of file Cached_Connect_Strategy_T.cpp. References ACE_Recyclable_State, and CONNECTION_CACHE_ENTRY.
00392 {
00393 // The wonders and perils of ACT
00394 CONNECTION_CACHE_ENTRY *entry = (CONNECTION_CACHE_ENTRY *) recycling_act;
00395
00396 // Mark the <svc_handler> in the cache as not being <in_use>.
00397 // Therefore recyclable is IDLE.
00398 entry->ext_id_.recycle_state (new_state);
00399
00400 return 0;
00401 }
|
|
|||||
|
Table that maintains the cache of connected <SVC_HANDLER>s.
Definition at line 175 of file Cached_Connect_Strategy_T.h. Referenced by caching_strategy, cleanup, purge_connections, and purge_i. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002