00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef CACHED_CONNECT_STRATEGY_T_H
00014 #define CACHED_CONNECT_STRATEGY_T_H
00015
00016 #include "ace/pre.h"
00017
00018 #include "ace/config-all.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 #include "ace/Strategies_T.h"
00025 #include "ace/Hash_Cache_Map_Manager_T.h"
00026 #include "ace/Caching_Strategies_T.h"
00027 #include "ace/Functor_T.h"
00028 #include "ace/Pair_T.h"
00029
00030
00031 #define ACE_Cached_Connect_Strategy_Ex ACCSE
00032
00033 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX>
00048 class ACE_Cached_Connect_Strategy_Ex
00049 : public ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>
00050 {
00051 public:
00052
00053 ACE_Cached_Connect_Strategy_Ex (
00054 CACHING_STRATEGY &caching_s,
00055 ACE_Creation_Strategy<SVC_HANDLER> *cre_s = 0,
00056 ACE_Concurrency_Strategy<SVC_HANDLER> *con_s = 0,
00057 ACE_Recycling_Strategy<SVC_HANDLER> *rec_s = 0,
00058 MUTEX *lock = 0,
00059 int delete_lock = 0);
00060
00061
00062 virtual ~ACE_Cached_Connect_Strategy_Ex (void);
00063
00064
00065 virtual int purge_connections (void);
00066
00067
00068
00069 virtual int mark_as_closed_i (const void *recycling_act);
00070
00071
00072
00073
00074
00075
00076 void cleanup (void);
00077
00078
00079 typedef ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>
00080 REFCOUNTED_HASH_RECYCLABLE_ADDRESS;
00081 typedef ACE_Hash_Cache_Map_Manager<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
00082 SVC_HANDLER *,
00083 ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
00084 ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
00085 CACHING_STRATEGY,
00086 ATTRIBUTES>
00087 CONNECTION_CACHE;
00088 typedef ACE_TYPENAME CONNECTION_CACHE::CACHE_ENTRY CONNECTION_CACHE_ENTRY;
00089 typedef ACE_TYPENAME CONNECTION_CACHE::key_type KEY;
00090 typedef ACE_TYPENAME CONNECTION_CACHE::mapped_type VALUE;
00091
00092 typedef ACE_Recyclable_Handler_Cleanup_Strategy<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
00093 ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,
00094 ACE_Hash_Map_Manager_Ex<REFCOUNTED_HASH_RECYCLABLE_ADDRESS,
00095 ACE_Pair<SVC_HANDLER *, ATTRIBUTES>,
00096 ACE_Hash<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
00097 ACE_Equal_To<REFCOUNTED_HASH_RECYCLABLE_ADDRESS>,
00098 MUTEX> >
00099 CLEANUP_STRATEGY;
00100
00101 typedef ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>
00102 CCSBASE;
00103
00104
00105 CACHING_STRATEGY &caching_strategy (void);
00106
00107 protected:
00108
00109
00110 int find (ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR> &search_addr,
00111 ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry);
00112
00113
00114 virtual int purge_i (const void *recycling_act);
00115
00116
00117 virtual int cache_i (const void *recycling_act);
00118
00119
00120 virtual int recycle_state_i (const void *recycling_act,
00121 ACE_Recyclable_State new_state);
00122 virtual ACE_Recyclable_State recycle_state_i (const void *recycling_act) const;
00123
00124
00125 virtual int cleanup_hint_i (const void *recycling_act,
00126 void **act_holder);
00127
00128
00129 int check_hint_i (SVC_HANDLER *&sh,
00130 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
00131 ACE_Time_Value *timeout,
00132 const ACE_PEER_CONNECTOR_ADDR &local_addr,
00133 int reuse_addr,
00134 int flags,
00135 int perms,
00136 ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
00137 int &found);
00138
00139 virtual int find_or_create_svc_handler_i (SVC_HANDLER *&sh,
00140 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
00141 ACE_Time_Value *timeout,
00142 const ACE_PEER_CONNECTOR_ADDR &local_addr,
00143 int reuse_addr,
00144 int flags,
00145 int perms,
00146 ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>, ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
00147 int &found);
00148
00149 virtual int connect_svc_handler_i (SVC_HANDLER *&sh,
00150 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
00151 ACE_Time_Value *timeout,
00152 const ACE_PEER_CONNECTOR_ADDR &local_addr,
00153 int reuse_addr,
00154 int flags,
00155 int perms,
00156 int &found);
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 virtual int cached_connect (SVC_HANDLER *&sh,
00168 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
00169 ACE_Time_Value *timeout,
00170 const ACE_PEER_CONNECTOR_ADDR &local_addr,
00171 int reuse_addr,
00172 int flags,
00173 int perms);
00174
00175
00176 CONNECTION_CACHE connection_cache_;
00177 };
00178
00179
00180
00181
00182 #define ACE_Bounded_Cached_Connect_Strategy ABCCS
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1,
00202 class CACHING_STRATEGY, class ATTRIBUTES,
00203 class MUTEX>
00204 class ACE_Bounded_Cached_Connect_Strategy
00205 : public ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>
00206 {
00207
00208 typedef ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>
00209 CCSEBASE;
00210
00211
00212 typedef ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>
00213 REFCOUNTED_HASH_RECYCLABLE_ADDRESS;
00214
00215 public:
00216
00217
00218 ACE_Bounded_Cached_Connect_Strategy (size_t max_size,
00219 CACHING_STRATEGY &caching_s,
00220 ACE_Creation_Strategy<SVC_HANDLER> *cre_s = 0,
00221 ACE_Concurrency_Strategy<SVC_HANDLER> *con_s = 0,
00222 ACE_Recycling_Strategy<SVC_HANDLER> *rec_s = 0,
00223 MUTEX *lock = 0,
00224 int delete_lock = 0);
00225
00226
00227 virtual ~ACE_Bounded_Cached_Connect_Strategy (void);
00228
00229
00230 ACE_ALLOC_HOOK_DECLARE;
00231
00232 protected:
00233
00234 virtual int find_or_create_svc_handler_i (SVC_HANDLER *&sh,
00235 const ACE_PEER_CONNECTOR_ADDR &remote_addr,
00236 ACE_Time_Value *timeout,
00237 const ACE_PEER_CONNECTOR_ADDR &local_addr,
00238 int reuse_addr,
00239 int flags,
00240 int perms,
00241 ACE_Hash_Map_Entry<ACE_Refcounted_Hash_Recyclable<ACE_PEER_CONNECTOR_ADDR>,
00242 ACE_Pair<SVC_HANDLER *, ATTRIBUTES> > *&entry,
00243 int &found);
00244
00245 protected:
00246
00247
00248 size_t max_size_;
00249 };
00250
00251 ACE_END_VERSIONED_NAMESPACE_DECL
00252
00253 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00254 #include "ace/Cached_Connect_Strategy_T.cpp"
00255 #endif
00256
00257 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00258 #pragma implementation ("Cached_Connect_Strategy_T.cpp")
00259 #endif
00260
00261 #include "ace/post.h"
00262 #endif