ACE 7.1.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX > Class Template 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 <Strategies_T.h>

Inheritance diagram for ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >:
Collaboration graph
[legend]

Public Types

typedef ACE_Creation_Strategy< SVC_HANDLERcreation_strategy_type
 
typedef ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2connect_strategy_type
 
typedef ACE_Concurrency_Strategy< SVC_HANDLERconcurrency_strategy_type
 
typedef ACE_Recycling_Strategy< SVC_HANDLERrecycling_strategy_type
 
typedef ACE_Creation_Strategy< SVC_HANDLERCREATION_STRATEGY
 
typedef ACE_Concurrency_Strategy< SVC_HANDLERCONCURRENCY_STRATEGY
 
typedef ACE_Recycling_Strategy< SVC_HANDLERRECYCLING_STRATEGY
 
typedef ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2CONNECT_STRATEGY
 
typedef ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX > SELF
 
typedef ACE_Refcounted_Hash_Recyclable< ACE_PEER_CONNECTOR_ADDRREFCOUNTED_HASH_RECYCLABLE_ADDRESS
 
typedef ACE_Hash_Map_Manager_Ex< REFCOUNTED_HASH_RECYCLABLE_ADDRESS, SVC_HANDLER *, ACE_Hash< REFCOUNTED_HASH_RECYCLABLE_ADDRESS >, ACE_Equal_To< REFCOUNTED_HASH_RECYCLABLE_ADDRESS >, ACE_Null_MutexCONNECTION_MAP
 
typedef CONNECTION_MAP::ITERATOR CONNECTION_MAP_ITERATOR
 
typedef CONNECTION_MAP::ENTRY CONNECTION_MAP_ENTRY
 
typedef ACE_Reverse_Lock< MUTEX > REVERSE_MUTEX
 
- Public Types inherited from ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >
typedef ACE_PEER_CONNECTOR_ADDR addr_type
 
typedef ACE_PEER_CONNECTOR connector_type
 
typedef SVC_HANDLER handler_type
 
typedef SVC_HANDLER::stream_type stream_type
 

Public Member Functions

 ACE_Cached_Connect_Strategy (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 *mutex=0, bool delete_lock=false)
 Constructor.
 
virtual ~ACE_Cached_Connect_Strategy ()
 Destructor.
 
virtual int open (ACE_Creation_Strategy< SVC_HANDLER > *cre_s, ACE_Concurrency_Strategy< SVC_HANDLER > *con_s, ACE_Recycling_Strategy< SVC_HANDLER > *rec_s)
 
virtual int make_svc_handler (SVC_HANDLER *&sh)
 Template method for making a new <svc_handler>
 
virtual int activate_svc_handler (SVC_HANDLER *svc_handler)
 Template method for activating a new svc_handler.
 
virtual int assign_recycler (SVC_HANDLER *svc_handler, ACE_Connection_Recycling_Strategy *recycler, const void *recycling_act)
 
virtual int prepare_for_recycling (SVC_HANDLER *svc_handler)
 Template method for preparing the svc_handler for recycling.
 
virtual int connect_svc_handler (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)
 
virtual int 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, bool reuse_addr, int flags, int perms)
 
virtual int purge (const void *recycling_act)
 Remove from cache.
 
virtual int cache (const void *recycling_act)
 Add to cache.
 
virtual int recycle_state (const void *recycling_act, ACE_Recyclable_State new_state)
 Get/Set <recycle_state>.
 
virtual ACE_Recyclable_State recycle_state (const void *recycling_act) const
 Get/Set recycle_state.
 
virtual int mark_as_closed (const void *recycling_act)
 Mark as closed.
 
virtual int mark_as_closed_i (const void *recycling_act)
 
virtual int cleanup_hint (const void *recycling_act, void **act_holder=0)
 Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>.
 
virtual ACE_Creation_Strategy< SVC_HANDLER > * creation_strategy () const
 
virtual ACE_Recycling_Strategy< SVC_HANDLER > * recycling_strategy () const
 
virtual ACE_Concurrency_Strategy< SVC_HANDLER > * concurrency_strategy () const
 
- Public Member Functions inherited from ACE_Connection_Recycling_Strategy
 ACE_Connection_Recycling_Strategy ()
 
virtual ~ACE_Connection_Recycling_Strategy ()=default
 Virtual Destructor.
 
- Public Member Functions inherited from ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >
 ACE_Connect_Strategy ()
 Default constructor.
 
virtual ACE_PEER_CONNECTORconnector () const
 Return a reference to the <peer_connector_>.
 
virtual ~ACE_Connect_Strategy ()
 
void dump () const
 Dump the state of an object.
 

Protected Member Functions

virtual int new_connection (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)
 Creates a new connection.
 
int find (REFCOUNTED_HASH_RECYCLABLE_ADDRESS &search_addr, CONNECTION_MAP_ENTRY *&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)
 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, CONNECTION_MAP_ENTRY *&entry, int &found)
 
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, CONNECTION_MAP_ENTRY *&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)
 

Protected Attributes

CONNECTION_MAP connection_map_
 Table that maintains the cache of connected SVC_HANDLERs.
 
MUTEX * lock_
 Mutual exclusion for this object.
 
bool delete_lock_
 Mutual exclusion for this object.
 
REVERSE_MUTEXreverse_lock_
 Reverse lock.
 
CREATION_STRATEGYcreation_strategy_
 Creation strategy for an <Connector>.
 
bool delete_creation_strategy_
 
CONCURRENCY_STRATEGYconcurrency_strategy_
 Concurrency strategy for an <Connector>.
 
bool delete_concurrency_strategy_
 
RECYCLING_STRATEGYrecycling_strategy_
 Recycling strategy for an <Connector>.
 
bool delete_recycling_strategy_
 
- Protected Attributes inherited from ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >
ACE_PEER_CONNECTOR connector_
 Factory that establishes connections actively.
 

Additional Inherited Members

- Public Attributes inherited from ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >
 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.
 

Detailed Description

template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX>
class ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >

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

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

Member Typedef Documentation

◆ CONCURRENCY_STRATEGY

◆ concurrency_strategy_type

◆ CONNECT_STRATEGY

◆ connect_strategy_type

◆ CONNECTION_MAP

◆ CONNECTION_MAP_ENTRY

◆ CONNECTION_MAP_ITERATOR

◆ CREATION_STRATEGY

◆ creation_strategy_type

◆ RECYCLING_STRATEGY

◆ recycling_strategy_type

◆ REFCOUNTED_HASH_RECYCLABLE_ADDRESS

◆ REVERSE_MUTEX

◆ SELF

Constructor & Destructor Documentation

◆ ACE_Cached_Connect_Strategy()

Constructor.

◆ ~ACE_Cached_Connect_Strategy()

Destructor.

Member Function Documentation

◆ activate_svc_handler()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::activate_svc_handler ( SVC_HANDLER * svc_handler)
virtual

Template method for activating a new svc_handler.

◆ assign_recycler()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::assign_recycler ( SVC_HANDLER * svc_handler,
ACE_Connection_Recycling_Strategy * recycler,
const void * recycling_act )
virtual

Template method for setting the recycler information of the svc_handler.

◆ cache()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::cache ( const void * recycling_act)
virtual

Add to cache.

Implements ACE_Connection_Recycling_Strategy.

◆ cache_i()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::cache_i ( const void * recycling_act)
protectedvirtual

◆ check_hint_i()

int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, 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,
bool reuse_addr,
int flags,
int perms,
CONNECTION_MAP_ENTRY *& entry,
int & found )
protected

◆ cleanup_hint()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::cleanup_hint ( const void * recycling_act,
void ** act_holder = 0 )
virtual

Cleanup hint and reset <*act_holder> to zero if <act_holder != 0>.

Implements ACE_Connection_Recycling_Strategy.

◆ cleanup_hint_i()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::cleanup_hint_i ( const void * recycling_act,
void ** act_holder )
protectedvirtual

◆ concurrency_strategy()

◆ connect_svc_handler() [1/2]

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, 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,
bool reuse_addr,
int flags,
int perms )
virtual

Checks to see if there is already a <SVC_HANDLER> in the cache connected to the <remote_addr>. If so, we return this pointer. Otherwise we establish the connection, put it into the cache, and return the SVC_HANDLER pointer. <[NOTE]>: the <{reuse_addr}> argument does NOT control re-use of addresses in the cache. Rather, if the underlying protocol requires a "dead time" prior to re-use of its addresses (TCP is a classic example of this), <{and}> the protocol provides a means by which to defeat the dead time, setting this argument to non-zero will defeat the dead-time requirement. <{Dev. Note: We might want to consider enhancing the interface at some point so that this also controls re-use of the cache.}>

Reimplemented from ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >.

◆ connect_svc_handler() [2/2]

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, 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,
bool reuse_addr,
int flags,
int perms )
virtual

The default behavior delegates to the <connect> method of the <PEER_CONNECTOR::connect>. Please check the documentation in Connector.h for more details.

Reimplemented from ACE_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >.

◆ connect_svc_handler_i()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, 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,
bool reuse_addr,
int flags,
int perms,
int & found )
protectedvirtual

◆ creation_strategy()

◆ find()

Find an idle handle.

◆ find_or_create_svc_handler_i()

int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, 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,
bool reuse_addr,
int flags,
int perms,
CONNECTION_MAP_ENTRY *& entry,
int & found )
protected

◆ make_svc_handler()

Template method for making a new <svc_handler>

◆ mark_as_closed()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::mark_as_closed ( const void * recycling_act)
virtual

Mark as closed.

Implements ACE_Connection_Recycling_Strategy.

◆ mark_as_closed_i()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::mark_as_closed_i ( const void * recycling_act)
virtual

Mark as closed (non-locking version). This method needs to be public as it is used in the cleanup of handlers where teh locked version causes a deadlock.

Implements ACE_Connection_Recycling_Strategy.

Reimplemented in ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER, ACE_PEER_CONNECTOR_1, CACHING_STRATEGY, ATTRIBUTES, MUTEX >, and ACE_Cached_Connect_Strategy_Ex< SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX >.

◆ new_connection()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::new_connection ( 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 )
protectedvirtual

Creates a new connection.

◆ open()

This methods allow you to change the strategies used by the cached connector.

◆ prepare_for_recycling()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::prepare_for_recycling ( SVC_HANDLER * svc_handler)
virtual

Template method for preparing the svc_handler for recycling.

◆ purge()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::purge ( const void * recycling_act)
virtual

Remove from cache.

Implements ACE_Connection_Recycling_Strategy.

◆ purge_i()

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::purge_i ( const void * recycling_act)
protectedvirtual

◆ recycle_state() [1/2]

virtual ACE_Recyclable_State ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::recycle_state ( const void * recycling_act) const
virtual

Get/Set recycle_state.

Implements ACE_Connection_Recycling_Strategy.

◆ recycle_state() [2/2]

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::recycle_state ( const void * recycling_act,
ACE_Recyclable_State new_state )
virtual

Get/Set <recycle_state>.

Implements ACE_Connection_Recycling_Strategy.

◆ recycle_state_i() [1/2]

virtual ACE_Recyclable_State ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::recycle_state_i ( const void * recycling_act) const
protectedvirtual

◆ recycle_state_i() [2/2]

virtual int ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::recycle_state_i ( const void * recycling_act,
ACE_Recyclable_State new_state )
protectedvirtual

◆ recycling_strategy()

Member Data Documentation

◆ concurrency_strategy_

Concurrency strategy for an <Connector>.

◆ connection_map_

Table that maintains the cache of connected SVC_HANDLERs.

◆ creation_strategy_

Creation strategy for an <Connector>.

◆ delete_concurrency_strategy_

bool ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::delete_concurrency_strategy_
protected

true if <Connector> created the concurrency strategy and thus should delete it, else false.

◆ delete_creation_strategy_

bool ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::delete_creation_strategy_
protected

true if <Connector> created the creation strategy and thus should delete it, else false.

◆ delete_lock_

Mutual exclusion for this object.

◆ delete_recycling_strategy_

bool ACE_Cached_Connect_Strategy< SVC_HANDLER, ACE_PEER_CONNECTOR_1, MUTEX >::delete_recycling_strategy_
protected

true if <Connector> created the recycling strategy and thus should delete it, else false.

◆ lock_

Mutual exclusion for this object.

◆ recycling_strategy_

Recycling strategy for an <Connector>.

◆ reverse_lock_

Reverse lock.


The documentation for this class was generated from the following file: