ACE  6.0.6
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
ACE_Cached_Connect_Strategy_Ex Class Reference

A connection strategy which caches connections to peers (represented by SVC_HANDLER instances), thereby allowing subsequent re-use of unused, but available, connections. More...

#include <Cached_Connect_Strategy_T.h>

Inheritance diagram for ACE_Cached_Connect_Strategy_Ex:
Inheritance graph
[legend]
Collaboration diagram for ACE_Cached_Connect_Strategy_Ex:
Collaboration graph
[legend]

List of all members.

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
CONNECTION_CACHE::CACHE_ENTRY 
CONNECTION_CACHE_ENTRY
typedef CONNECTION_CACHE::key_type KEY
typedef
CONNECTION_CACHE::mapped_type 
VALUE
typedef
ACE_Recyclable_Handler_Cleanup_Strategy
< REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
std::pair< SVC_HANDLER
*, ATTRIBUTES >
, ACE_Hash_Map_Manager_Ex
< REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
std::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 >, std::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 recycle_state (non-locking version).
virtual ACE_Recyclable_State recycle_state_i (const void *recycling_act) const
 Get <recycle_state> (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, bool reuse_addr, int flags, int perms, ACE_Hash_Map_Entry< ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR >, std::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, bool reuse_addr, int flags, int perms, ACE_Hash_Map_Entry< ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR >, std::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, bool 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, bool reuse_addr, int flags, int perms)

Protected Attributes

CONNECTION_CACHE connection_cache_
 Table that maintains the cache of connected SVC_HANDLERs.

Detailed Description

A connection strategy which caches connections to peers (represented by SVC_HANDLER instances), thereby allowing subsequent re-use of unused, but available, connections.

<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.


Member Typedef Documentation

typedef ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX> ACE_Cached_Connect_Strategy_Ex::CCSBASE

Constructor & Destructor Documentation

ACE_Cached_Connect_Strategy_Ex::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::~ACE_Cached_Connect_Strategy_Ex ( void  ) [virtual]

Destructor.


Member Function Documentation

virtual int ACE_Cached_Connect_Strategy_Ex::cache_i ( const void *  recycling_act) [protected, virtual]

Add to cache (non-locking version).

Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >.

virtual int ACE_Cached_Connect_Strategy_Ex::cached_connect ( SVC_HANDLER *&  sh,
const ACE_PEER_CONNECTOR_ADDR &  remote_addr,
ACE_Time_Value timeout,
const ACE_PEER_CONNECTOR_ADDR &  local_addr,
bool  reuse_addr,
int  flags,
int  perms 
) [protected, virtual]

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.

CACHING_STRATEGY& ACE_Cached_Connect_Strategy_Ex::caching_strategy ( void  )
int ACE_Cached_Connect_Strategy_Ex::check_hint_i ( SVC_HANDLER *&  sh,
const ACE_PEER_CONNECTOR_ADDR &  remote_addr,
ACE_Time_Value timeout,
const ACE_PEER_CONNECTOR_ADDR &  local_addr,
bool  reuse_addr,
int  flags,
int  perms,
ACE_Hash_Map_Entry< ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR >, std::pair< SVC_HANDLER *, ATTRIBUTES > > *&  entry,
int &  found 
) [protected]
void ACE_Cached_Connect_Strategy_Ex::cleanup ( void  )

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_>.

virtual int ACE_Cached_Connect_Strategy_Ex::cleanup_hint_i ( const void *  recycling_act,
void **  act_holder 
) [protected, virtual]

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 >.

virtual int ACE_Cached_Connect_Strategy_Ex::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,
bool  reuse_addr,
int  flags,
int  perms,
int &  found 
) [protected, virtual]
int ACE_Cached_Connect_Strategy_Ex::find ( ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR > &  search_addr,
ACE_Hash_Map_Entry< ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR >, std::pair< SVC_HANDLER *, ATTRIBUTES > > *&  entry 
) [protected]

Find an idle handle.

virtual int ACE_Cached_Connect_Strategy_Ex::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,
bool  reuse_addr,
int  flags,
int  perms,
ACE_Hash_Map_Entry< ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDR >, std::pair< SVC_HANDLER *, ATTRIBUTES > > *&  entry,
int &  found 
) [protected, virtual]
virtual int ACE_Cached_Connect_Strategy_Ex::mark_as_closed_i ( const void *  recycling_act) [virtual]

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 >.

virtual int ACE_Cached_Connect_Strategy_Ex::purge_connections ( void  ) [virtual]

Explicit purging of connection entries from the connection cache.

virtual int ACE_Cached_Connect_Strategy_Ex::purge_i ( const void *  recycling_act) [protected, virtual]

Remove from cache (non-locking version).

Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >.

virtual int ACE_Cached_Connect_Strategy_Ex::recycle_state_i ( const void *  recycling_act,
ACE_Recyclable_State  new_state 
) [protected, virtual]

Get/Set recycle_state (non-locking version).

Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >.

virtual ACE_Recyclable_State ACE_Cached_Connect_Strategy_Ex::recycle_state_i ( const void *  recycling_act) const [protected, virtual]

Get <recycle_state> (non-locking version).

Reimplemented from ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX >.


Member Data Documentation

Table that maintains the cache of connected SVC_HANDLERs.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines