diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-05-05 15:13:03 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-05-05 15:13:03 +0000 |
commit | 36dd71e23b8f7d59a3854a877bda8d7964dc0a41 (patch) | |
tree | 9ad89ebd1e9dc6eb0b86db06f334dd42fc47a09d /ace/Strategies_T.h | |
parent | 64f4ca2225c58d125b79b65a47fc66cd90c2ac40 (diff) | |
download | ATCD-36dd71e23b8f7d59a3854a877bda8d7964dc0a41.tar.gz |
*** empty log message ***
Diffstat (limited to 'ace/Strategies_T.h')
-rw-r--r-- | ace/Strategies_T.h | 133 |
1 files changed, 74 insertions, 59 deletions
diff --git a/ace/Strategies_T.h b/ace/Strategies_T.h index 8c6fedb0cab..3d02e5bfee3 100644 --- a/ace/Strategies_T.h +++ b/ace/Strategies_T.h @@ -19,6 +19,7 @@ #include "ace/Service_Config.h" #include "ace/Synch_Options.h" +#include "ace/Hash_Map_Manager.h" template <class SVC_HANDLER> class ACE_Creation_Strategy @@ -477,77 +478,91 @@ protected: template <class SVC_HANDLER> class ACE_NOOP_Creation_Strategy : public ACE_Creation_Strategy<SVC_HANDLER> -// = TITLE -// -// Implements a no-op creation strategy in order to defer -// decisions regarding creation to some later point in time, such -// as in connect or accept strategy. -// -// = NOTES -// -// An example of the use of this is in the -// <ACE_Cached_Connect_Strategy\<\>>, which only returns a -// single connection for a given endpoint. + // = TITLE + // + // Implements a no-op creation strategy in order to defer + // decisions regarding creation to some later point in time, such + // as in connect or accept strategy. + // + // = DESCRIPTION + // An example of the use of this is in the + // <ACE_Cached_Connect_Strategy>, which only returns a single + // connection for a given endpoint. { public: - virtual int make_svc_handler(SVC_HANDLER*&) { return 0; } - // This is a no-op. + virtual int make_svc_handler (SVC_HANDLER*&) { return 0; } + // This is a no-op. }; template <class ADDR_T, class SVC_HANDLER> -class Hash_Addr : public ADDR_T -// = TITLE -// Internal class to compute hash values on addresses in <ACE_Cached_Connect_Strategy>. -// -// = DESCRIPTION -// Intended to be used as a key to an <ACE_Hash_Map>. -// -// = NOTES -// The SVC_HANDLER class is expected to implement the following methods: -// int in_use() const; -// void in_use(int is_used); -// +class ACE_Hash_Addr : public ADDR_T + // = TITLE + // Internal class to compute hash values on addresses in + // <ACE_Cached_Connect_Strategy>. + // + // = DESCRIPTION + // Intended to be used as a key to an <ACE_Hash_Map>. The + // <SVC_HANDLER> class is expected to implement the following + // methods: int in_use() const; void in_use(int is_used); + // Likewise, the <ADDR_T> parameter/subclass is typically + // <ACE_INET_Addr>. { public: - Hash_Addr(); - Hash_Addr(const ADDR_T& a, SVC_HANDLER* sh = 0); - // Pre-compute hash value - - size_t hash() const; // Computes & return hash value - virtual int operator==(const Hash_Addr<ADDR_T,SVC_HANDLER>& rhs) const; - // Compares two hash values - - //private: - size_t hash_value_; // Pre-computed hash-value. - SVC_HANDLER* svc_handler_; - // Pointer to associated <SVC_HANDLER> which is used - // to detect "in-use" SVC_HANDLERs so we can skip - // over them. See NOTES for details on methods required - // on SVC_HANDLER. + // = Initialization methods. + ACE_Hash_Addr (void); + // Default constructor. + + ACE_Hash_Addr (const ADDR_T &a, + SVC_HANDLER *sh = 0); + // Pre-compute hash value. + + size_t hash (void) const; + // Computes and returns hash value. This "caches" the hash value to + // improve performance. + + int operator== (const ACE_Hash_Addr<ADDR_T, SVC_HANDLER> &rhs) const; + // Compares two hash values. + +private: + size_t hash_i (const ADDR_T &) const; + // This is the method that actually performs the non-cached hash + // computation. It should typically be specialized. + + int compare_i (const ADDR_T &b1, const ADDR_T &bs) const; + // Compares two hash values. This is the method that actually + // performs the non-cached hash computation. It should typically be + // specialized. + + size_t hash_value_; + // Pre-computed hash-value. + + SVC_HANDLER *svc_handler_; + // Pointer to associated <SVC_HANDLER> which is used to detect + // "in-use" <SVC_HANDLER>s so we can ignore them. See <DESCRIPTION> + // for details on methods required on <SVC_HANDLER>. }; template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class MUTEX> -class ACE_Cached_Connect_Strategy : - public ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> +class ACE_Cached_Connect_Strategy : public ACE_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2> + // = TITLE + // + // = DESCRIPTION { public: - 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); - // 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. - //private: - ACE_Hash_Map_Manager< Hash_Addr<ACE_PEER_CONNECTOR_ADDR,SVC_HANDLER>, SVC_HANDLER*, MUTEX> connection_cache_; + 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); + // 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. + +private: + ACE_Hash_Map_Manager <ACE_Hash_Addr <ACE_PEER_CONNECTOR_ADDR,SVC_HANDLER>, SVC_HANDLER*, MUTEX> connection_cache_; }; template <class SVC_HANDLER> |