00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ACE_TIMER_HASH_T_H
00014 #define ACE_TIMER_HASH_T_H
00015 #include "ace/pre.h"
00016
00017 #include "ace/Timer_Queue_T.h"
00018
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif
00022
00023 #include "ace/Free_List.h"
00024
00025
00026 template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
00027 class ACE_Timer_Hash_T;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 template <class TYPE, class FUNCTOR, class ACE_LOCK>
00038 class ACE_Timer_Hash_Upcall
00039 {
00040 public:
00041 typedef ACE_Timer_Queue_T<ACE_Event_Handler *,
00042 ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>,
00043 ACE_Null_Mutex>
00044 TIMER_QUEUE;
00045
00046
00047
00048 ACE_Timer_Hash_Upcall (void);
00049
00050
00051 ACE_Timer_Hash_Upcall (ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> *timer_hash);
00052
00053
00054 int timeout (TIMER_QUEUE &timer_queue,
00055 ACE_Event_Handler *handler,
00056 const void *arg,
00057 const ACE_Time_Value &cur_time);
00058
00059
00060 int cancellation (TIMER_QUEUE &timer_queue,
00061 ACE_Event_Handler *handler);
00062
00063
00064
00065 int deletion (TIMER_QUEUE &timer_queue,
00066 ACE_Event_Handler *handler,
00067 const void *arg);
00068
00069 private:
00070
00071 ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> *timer_hash_;
00072
00073
00074 ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Hash_Upcall (const ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK> &))
00075 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK> &))
00076 };
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
00088 class ACE_Timer_Hash_Iterator_T : public ACE_Timer_Queue_Iterator_T <TYPE, FUNCTOR, ACE_LOCK>
00089 {
00090 public:
00091
00092 ACE_Timer_Hash_Iterator_T (ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &);
00093
00094
00095 virtual void first (void);
00096
00097
00098 virtual void next (void);
00099
00100
00101 virtual int isdone (void) const;
00102
00103
00104 virtual ACE_Timer_Node_T<TYPE> *item (void);
00105
00106 protected:
00107
00108 ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &timer_hash_;
00109
00110
00111 size_t position_;
00112
00113
00114 ACE_Timer_Queue_Iterator_T<TYPE, ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK>, ACE_Null_Mutex> *iter_;
00115 };
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 template <class TYPE, class FUNCTOR, class ACE_LOCK, class BUCKET>
00128 class ACE_Timer_Hash_T : public ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK>
00129 {
00130 public:
00131
00132 typedef ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>
00133 HASH_ITERATOR;
00134
00135
00136 friend class ACE_Timer_Hash_Iterator_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>;
00137
00138
00139 typedef ACE_Timer_Queue_T<TYPE, FUNCTOR, ACE_LOCK> INHERITED;
00140
00141
00142
00143
00144
00145
00146
00147
00148 ACE_Timer_Hash_T (size_t table_size,
00149 FUNCTOR *upcall_functor = 0,
00150 ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0);
00151
00152
00153
00154
00155
00156
00157
00158
00159 ACE_Timer_Hash_T (FUNCTOR *upcall_functor = 0, ACE_Free_List<ACE_Timer_Node_T <TYPE> > *freelist = 0);
00160
00161
00162 virtual ~ACE_Timer_Hash_T (void);
00163
00164
00165 virtual int is_empty (void) const;
00166
00167
00168
00169 virtual const ACE_Time_Value &earliest_time (void) const;
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 virtual long schedule (const TYPE &type,
00183 const void *act,
00184 const ACE_Time_Value &future_time,
00185 const ACE_Time_Value &interval = ACE_Time_Value::zero);
00186
00187
00188
00189
00190
00191
00192
00193
00194 virtual int reset_interval (long timer_id,
00195 const ACE_Time_Value &interval);
00196
00197
00198
00199
00200
00201
00202 virtual int cancel (const TYPE &type,
00203 int dont_call_handle_close = 1);
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 virtual int cancel (long timer_id,
00215 const void **act = 0,
00216 int dont_call_handle_close = 1);
00217
00218
00219
00220
00221
00222
00223 virtual int expire (void);
00224
00225
00226
00227
00228
00229
00230 virtual int expire (const ACE_Time_Value ¤t_time);
00231
00232
00233 virtual ACE_Timer_Queue_Iterator_T<TYPE, FUNCTOR, ACE_LOCK> &iter (void);
00234
00235
00236 virtual ACE_Timer_Node_T<TYPE> *remove_first (void);
00237
00238
00239 virtual void dump (void) const;
00240
00241
00242 virtual ACE_Timer_Node_T<TYPE> *get_first (void);
00243
00244 private:
00245
00246 virtual void reschedule (ACE_Timer_Node_T<TYPE> *);
00247
00248
00249 void find_new_earliest (void);
00250
00251
00252 size_t size_;
00253
00254
00255 BUCKET **table_;
00256
00257
00258 size_t table_size_;
00259
00260
00261 ACE_Timer_Hash_Upcall<TYPE, FUNCTOR, ACE_LOCK> table_functor_;
00262
00263
00264 size_t earliest_position_;
00265
00266
00267 HASH_ITERATOR *iterator_;
00268
00269 #if defined (ACE_WIN64)
00270
00271
00272 ptrdiff_t pointer_base_;
00273 #endif
00274
00275
00276 ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Hash_T (const ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &))
00277 ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &))
00278 };
00279
00280 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) && !defined(ACE_HAS_BROKEN_HPUX_TEMPLATES)
00281 #include "ace/Timer_Hash_T.cpp"
00282 #endif
00283
00284 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00285 #pragma implementation ("Timer_Hash_T.cpp")
00286 #endif
00287
00288 #include "ace/post.h"
00289 #endif