SVC_HANDLER
instances), thereby allowing
subsequent re-use of unused, but available, connections.
#include <ace/ACE_Strategies_T.h>
template<class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> class ACE_Cached_Connect_Strategy : public ACE_Connection_Recycling_Strategy, public ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> {
public:
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 );
virtual ~ACE_Cached_Connect_Strategy (void);
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);
virtual int activate_svc_handler (SVC_HANDLER *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);
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, int reuse_addr, int flags, int perms );
virtual int purge (const void *recycling_act);
virtual int cache (const void *recycling_act);
private:
typedef ACE_Creation_Strategy<SVC_HANDLER> CREATION_STRATEGY;
typedef ACE_Concurrency_Strategy<SVC_HANDLER> CONCURRENCY_STRATEGY;typedef ACE_Recycling_Strategy<SVC_HANDLER> RECYCLING_STRATEGY;
typedef ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> CONNECT_STRATEGY;typedef ACE_Hash_Addr<ACE_PEER_CONNECTOR_ADDR> ADDRESS;
typedef ACE_Hash_Map_Manager <ADDRESS, SVC_HANDLER *, ACE_Null_Mutex> CONNECTION_MAP; typedef ACE_Hash_Map_Iterator <ADDRESS, SVC_HANDLER *, ACE_Null_Mutex> CONNECTION_MAP_ITERATOR; typedef ACE_Hash_Map_Entry<ADDRESS, SVC_HANDLER *> CONNECTION_MAP_ENTRY;CONNECTION_MAP connection_cache_;
MUTEX lock_;
CREATION_STRATEGY *creation_strategy_;
int delete_creation_strategy_;
CONCURRENCY_STRATEGY *concurrency_strategy_;
int delete_concurrency_strategy_;
RECYCLING_STRATEGY *recycling_strategy_;
int delete_recycling_strategy_;
};
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.
typedef ACE_Creation_Strategy<SVC_HANDLER> CREATION_STRATEGY;
typedef ACE_Concurrency_Strategy<SVC_HANDLER> CONCURRENCY_STRATEGY;
typedef ACE_Recycling_Strategy<SVC_HANDLER> RECYCLING_STRATEGY;
typedef ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> CONNECT_STRATEGY;
typedef ACE_Hash_Addr<ACE_PEER_CONNECTOR_ADDR> ADDRESS;
typedef ACE_Hash_Map_Manager <ADDRESS, SVC_HANDLER *, ACE_Null_Mutex> CONNECTION_MAP;
typedef ACE_Hash_Map_Iterator <ADDRESS, SVC_HANDLER *, ACE_Null_Mutex> CONNECTION_MAP_ITERATOR;
typedef ACE_Hash_Map_Entry<ADDRESS, SVC_HANDLER *> CONNECTION_MAP_ENTRY;
CONNECTION_MAP connection_cache_;
SVC_HANDLER
s.
MUTEX lock_;
CREATION_STRATEGY *creation_strategy_;
Connector
.
int delete_creation_strategy_;
Connector
created the creation strategy and thus should
delete it, else 0.
CONCURRENCY_STRATEGY *concurrency_strategy_;
Connector
.
int delete_concurrency_strategy_;
Connector
created the concurrency strategy and thus should
delete it, else 0.
RECYCLING_STRATEGY *recycling_strategy_;
Connector
.
int delete_recycling_strategy_;
Connector
created the recycling strategy and thus should
delete it, else 0.
ACE_Hash_Addr::compare_i()
and
ACE_Hash_Addr::hash_i()
based on the address type and the
service handler type. For example, a specialization using
ACE_INET_Addr
and My_Service_Handler
might be:
size_t
ACE_Hash_Addr<ACE_INET_Addr, My_Service_Handler>::hash_i(const ACE_INET_Addr &a)
{
return ...;
}
ACE_Hash_Addr
.