00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TAO_CONNECTION_CACHE_MANAGER_H
00014 #define TAO_CONNECTION_CACHE_MANAGER_H
00015
00016 #include "ace/pre.h"
00017 #include "ace/Null_Mutex.h"
00018
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 #define ACE_LACKS_PRAGMA_ONCE
00021 #endif
00022
00023 #include "ace/Hash_Map_Manager_T.h"
00024
00025 #include "tao/Cache_Entries.h"
00026 #include "tao/orbconf.h"
00027
00028 #if defined (TAO_HAS_MONITOR_POINTS) && (TAO_HAS_MONITOR_POINTS == 1)
00029 #include "ace/Monitor_Size.h"
00030 #endif
00031
00032 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00033 class ACE_Handle_Set;
00034 template <class T> class ACE_Unbounded_Set;
00035 template <class T> class ACE_Unbounded_Set_Iterator;
00036 ACE_END_VERSIONED_NAMESPACE_DECL
00037
00038 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00039
00040 class TAO_Connection_Handler;
00041 class TAO_ORB_Core;
00042 class TAO_Resource_Factory;
00043 class TAO_Connection_Purging_Strategy;
00044
00045 template <class ACE_COND_MUTEX> class TAO_Condition;
00046
00047 namespace TAO
00048 {
00049 typedef ACE_Unbounded_Set<TAO_Connection_Handler*> Connection_Handler_Set;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 class TAO_Export Transport_Cache_Manager
00065 {
00066 public:
00067
00068 typedef ACE_Hash_Map_Manager_Ex <Cache_ExtId,
00069 Cache_IntId,
00070 ACE_Hash<Cache_ExtId>,
00071 ACE_Equal_To<Cache_ExtId>,
00072 ACE_Null_Mutex>
00073 HASH_MAP;
00074
00075 typedef HASH_MAP::iterator HASH_MAP_ITER;
00076
00077 typedef ACE_Hash_Map_Entry <Cache_ExtId,
00078 Cache_IntId>
00079 HASH_MAP_ENTRY;
00080
00081 typedef TAO_Condition<TAO_SYNCH_MUTEX> CONDITION;
00082
00083
00084
00085 Transport_Cache_Manager (TAO_ORB_Core &orb_core);
00086
00087
00088 ~Transport_Cache_Manager (void);
00089
00090
00091
00092
00093
00094
00095
00096
00097 int cache_transport (TAO_Transport_Descriptor_Interface *prop,
00098 TAO_Transport *transport);
00099
00100
00101
00102 int cache_idle_transport (TAO_Transport_Descriptor_Interface *prop,
00103 TAO_Transport *transport);
00104
00105
00106
00107 int find_transport (TAO_Transport_Descriptor_Interface *prop,
00108 TAO_Transport *&transport);
00109
00110
00111 int purge (void);
00112
00113
00114 int purge_entry (HASH_MAP_ENTRY *&);
00115
00116
00117 void mark_invalid (HASH_MAP_ENTRY *&);
00118
00119
00120 int make_idle (HASH_MAP_ENTRY *&entry);
00121
00122
00123
00124 int update_entry (HASH_MAP_ENTRY *&entry);
00125
00126
00127
00128 int close (Connection_Handler_Set &handlers);
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 bool blockable_client_transports (Connection_Handler_Set &handlers);
00141
00142
00143 size_t current_size (void) const;
00144
00145
00146 size_t total_size (void) const;
00147
00148
00149 HASH_MAP &map (void);
00150
00151 private:
00152
00153
00154 int bind (Cache_ExtId &ext_id,
00155 Cache_IntId &int_id);
00156
00157
00158
00159 int find (const Cache_ExtId &key,
00160 Cache_IntId &value);
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 int bind_i (Cache_ExtId &ext_id,
00171 Cache_IntId &int_id);
00172
00173
00174
00175
00176
00177
00178
00179 int find_i (const Cache_ExtId &key,
00180 Cache_IntId &value);
00181
00182
00183 int make_idle_i (HASH_MAP_ENTRY *&entry);
00184
00185
00186 int close_i (Connection_Handler_Set &handlers);
00187
00188
00189 int purge_entry_i (HASH_MAP_ENTRY *&entry);
00190
00191
00192 void mark_invalid_i (HASH_MAP_ENTRY *&);
00193
00194 private:
00195
00196
00197
00198
00199
00200
00201
00202
00203 int get_last_index_bind (Cache_ExtId &key,
00204 Cache_IntId &val,
00205 HASH_MAP_ENTRY *&entry);
00206
00207
00208
00209
00210
00211
00212 bool is_entry_idle (HASH_MAP_ENTRY *&entry);
00213
00214 #if !defined(ACE_LACKS_QSORT)
00215
00216 static int cpscmp(const void* a, const void* b);
00217 #endif
00218
00219 typedef HASH_MAP_ENTRY** DESCRIPTOR_SET;
00220
00221
00222 void sort_set (DESCRIPTOR_SET& entries, int size);
00223
00224
00225
00226 int fill_set_i (DESCRIPTOR_SET& sorted_set);
00227
00228
00229
00230
00231
00232
00233 int wait_for_connection (Cache_ExtId &extid);
00234
00235
00236 int is_wakeup_useful (Cache_ExtId &extid);
00237
00238
00239 bool blockable_client_transports_i (Connection_Handler_Set &handlers);
00240
00241 private:
00242
00243 int percent_;
00244
00245
00246 TAO_Connection_Purging_Strategy *purging_strategy_;
00247
00248
00249 HASH_MAP cache_map_;
00250
00251
00252 CONDITION *condition_;
00253
00254
00255 ACE_Lock *cache_lock_;
00256
00257
00258 CORBA::ULong muxed_number_;
00259
00260
00261 int no_waiting_threads_;
00262
00263
00264
00265
00266
00267 Cache_ExtId *last_entry_returned_;
00268
00269 #if defined (TAO_HAS_MONITOR_POINTS) && (TAO_HAS_MONITOR_POINTS == 1)
00270
00271 ACE::Monitor_Control::Size_Monitor *purge_monitor_;
00272
00273
00274 ACE::Monitor_Control::Size_Monitor *size_monitor_;
00275 #endif
00276 };
00277
00278 }
00279
00280 TAO_END_VERSIONED_NAMESPACE_DECL
00281
00282 #if defined (__ACE_INLINE__)
00283 # include "tao/Transport_Cache_Manager.inl"
00284 #endif
00285
00286 #include "ace/post.h"
00287
00288 #endif