File: ACE_Timer_Wheel_T.3

package info (click to toggle)
ace 5.2.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 26,856 kB
  • ctags: 18,677
  • sloc: cpp: 171,831; makefile: 48,840; sh: 10,192; perl: 8,582; exp: 787; yacc: 387; lex: 140; csh: 20
file content (284 lines) | stat: -rw-r--r-- 12,474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
.TH ACE_Timer_Wheel_T 3 "1 Dec 2001" "ACE" \" -*- nroff -*-
.ad l
.nh
.SH NAME
ACE_Timer_Wheel_T \- Provides a Timing Wheel version of Timer Queue. 
.SH SYNOPSIS
.br
.PP
\fC#include <Timer_Wheel_T.h>\fR
.PP
Inherits \fBACE_Timer_Queue_T< TYPE,FUNCTOR,ACE_LOCK >\fR.
.PP
.SS Public Types

.in +1c
.ti -1c
.RI "typedef \fBACE_Timer_Wheel_Iterator_T\fR<TYPE, FUNCTOR, ACE_LOCK> \fBWHEEL_ITERATOR\fR"
.br
.RI "\fIType of iterator.\fR"
.ti -1c
.RI "typedef \fBACE_Timer_Queue_T\fR<TYPE, FUNCTOR, ACE_LOCK> \fBINHERITED\fR"
.br
.RI "\fIType inherited from.\fR"
.in -1c
.SS Public Methods

.in +1c
.ti -1c
.RI "\fBACE_Timer_Wheel_T\fR (FUNCTOR *upcall_functor = 0, \fBACE_Free_List\fR<\fBACE_Timer_Node_T\fR <TYPE> > *freelist = 0)"
.br
.RI "\fIDefault constructor.\fR"
.ti -1c
.RI "\fBACE_Timer_Wheel_T\fR (size_t wheelsize, size_t resolution, size_t prealloc = 0, FUNCTOR *upcall_functor = 0, \fBACE_Free_List\fR<\fBACE_Timer_Node_T\fR <TYPE> > *freelist = 0)"
.br
.RI "\fIConstructor with opportunities to set the wheelsize and resolution.\fR"
.ti -1c
.RI "virtual \fB~ACE_Timer_Wheel_T\fR (void)"
.br
.RI "\fIDestructor.\fR"
.ti -1c
.RI "virtual int \fBis_empty\fR (void) const"
.br
.RI "\fITrue if queue is empty, else false.\fR"
.ti -1c
.RI "virtual const \fBACE_Time_Value\fR& \fBearliest_time\fR (void) const"
.br
.RI "\fIReturns the time of the earlier node in the . Must be called on a non-empty queue.\fR"
.ti -1c
.RI "virtual long \fBschedule\fR (const TYPE &type, const void *act, const \fBACE_Time_Value\fR &delay, const \fBACE_Time_Value\fR &interval = \fBACE_Time_Value::zero\fR)"
.br
.RI "\fISchedules a timer.\fR"
.ti -1c
.RI "virtual int \fBreset_interval\fR (long timer_id, const \fBACE_Time_Value\fR &interval)"
.br
.RI "\fIChanges the interval of a timer (and can make it periodic or non periodic by setting it to \fBACE_Time_Value::zero\fR or not).\fR"
.ti -1c
.RI "virtual int \fBcancel\fR (const TYPE &type, int dont_call_handle_close = 1)"
.br
.RI "\fICancel all timer associated with <type>. If <dont_call> is 0 then the <functor> will be invoked. Returns number of timers cancelled.\fR"
.ti -1c
.RI "virtual int \fBcancel\fR (long timer_id, const void **act = 0, int dont_call_handle_close = 1)"
.br
.ti -1c
.RI "virtual int \fBexpire\fR (void)"
.br
.RI "\fIRun the <functor> for all timers whose values are <= . Also accounts for <timer_skew>. Returns the number of timers canceled.\fR"
.ti -1c
.RI "int \fBexpire\fR (const \fBACE_Time_Value\fR &)"
.br
.ti -1c
.RI "virtual \fBACE_Timer_Queue_Iterator_T\fR<TYPE, FUNCTOR, ACE_LOCK>& \fBiter\fR (void)"
.br
.RI "\fIReturns a pointer to this 's iterator.\fR"
.ti -1c
.RI "virtual \fBACE_Timer_Node_T\fR<TYPE>* \fBremove_first\fR (void)"
.br
.RI "\fIRemoves the earliest node from the queue and returns it.\fR"
.ti -1c
.RI "virtual void \fBdump\fR (void) const"
.br
.RI "\fIDump the state of an object.\fR"
.ti -1c
.RI "virtual \fBACE_Timer_Node_T\fR<TYPE>* \fBget_first\fR (void)"
.br
.RI "\fIReads the earliest node from the queue and returns it.\fR"
.in -1c
.SS Private Methods

.in +1c
.ti -1c
.RI "virtual void \fBreschedule\fR (\fBACE_Timer_Node_T\fR<TYPE> *)"
.br
.RI "\fIReschedule an "interval" node.\fR"
.ti -1c
.RI "\fBACE_Timer_Wheel_T\fR (const ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> &)"
.br
.ti -1c
.RI "void \fBoperator=\fR (const ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> &)"
.br
.in -1c
.SS Private Attributes

.in +1c
.ti -1c
.RI "\fBACE_Timer_Node_T\fR<TYPE>** \fBwheel_\fR"
.br
.RI "\fITiming Wheel.\fR"
.ti -1c
.RI "size_t \fBwheel_size_\fR"
.br
.RI "\fISize of the timing wheel.\fR"
.ti -1c
.RI "size_t \fBresolution_\fR"
.br
.RI "\fIResolution (in microsoconds) of the timing wheel.\fR"
.ti -1c
.RI "size_t \fBearliest_pos_\fR"
.br
.RI "\fIIndex of the list with the earliest time.\fR"
.ti -1c
.RI "long \fBsize_\fR"
.br
.RI "\fIKeeps track of the size of the queue.\fR"
.ti -1c
.RI "\fBWHEEL_ITERATOR\fR* \fBiterator_\fR"
.br
.RI "\fIIterator used to expire timers.\fR"
.ti -1c
.RI "\fBACE_Timer_Node_T\fR<TYPE>* \fBfreelist_\fR"
.br
.RI "\fIPointer to the freelist of >.\fR"
.in -1c
.SS Friends

.in +1c
.ti -1c
.RI "class \fBACE_Timer_Wheel_Iterator_T< TYPE,FUNCTOR,ACE_LOCK >\fR"
.br
.in -1c
.SH DETAILED DESCRIPTION
.PP 

.SS template<class TYPE, class FUNCTOR, class ACE_LOCK>  template class ACE_Timer_Wheel_T
Provides a Timing Wheel version of Timer Queue.
.PP
.PP
 This implementation uses a hash table of ordered doubly- linked lists of absolute times. The other enhancements to Timer List include using the pointer to the node as the timer id (to speed up removing), adding a free list and the ability to preallocate nodes. Timer Wheel is based on the timing wheel implementation used in Adam M. Costello and George Varghese's paper "Redesigning the BSD Callout and Timer Facilities" (http://dworkin.wustl.edu/~varghese/PAPERS/newbsd.ps.Z) 
.PP
.SH MEMBER TYPEDEF DOCUMENTATION
.PP 
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> typedef \fBACE_Timer_Queue_T\fR<TYPE, FUNCTOR, ACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::INHERITED
.PP
Type inherited from.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> typedef \fBACE_Timer_Wheel_Iterator_T\fR<TYPE, FUNCTOR, ACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::WHEEL_ITERATOR
.PP
Type of iterator.
.PP
.SH CONSTRUCTOR & DESTRUCTOR DOCUMENTATION
.PP 
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> (FUNCTOR * upcall_functor = 0, \fBACE_Free_List\fR< \fBACE_Timer_Node_T\fR< TYPE > >* freelist = 0)
.PP
Default constructor.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> (size_t wheelsize, size_t resolution, size_t prealloc = 0, FUNCTOR * upcall_functor = 0, \fBACE_Free_List\fR< \fBACE_Timer_Node_T\fR< TYPE > >* freelist = 0)
.PP
Constructor with opportunities to set the wheelsize and resolution.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::~ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> (void)\fC [virtual]\fR
.PP
Destructor.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK> (const ACE_Timer_Wheel_T< TYPE,FUNCTOR,ACE_LOCK >&)\fC [private]\fR
.PP
.SH MEMBER FUNCTION DOCUMENTATION
.PP 
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> virtual int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (long timer_id, const void ** act = 0, int dont_call_handle_close = 1)\fC [virtual]\fR
.PP
Cancel the single timer that matches the <timer_id> value (which was returned from the <schedule> method). If act is non-NULL then it will be set to point to the ``magic cookie'' argument passed in when the timer was registered. This makes it possible to free up the memory and avoid memory leaks. If <dont_call_handle_close> is 0 then the <functor> will be invoked, which typically calls the <handle_close> hook. Returns 1 if cancellation succeeded and 0 if the <timer_id> wasn't found. 
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::cancel (const TYPE & type, int dont_call_handle_close = 1)\fC [virtual]\fR
.PP
Cancel all timer associated with <type>. If <dont_call> is 0 then the <functor> will be invoked. Returns number of timers cancelled.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> void ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::dump (void) const\fC [virtual]\fR
.PP
Dump the state of an object.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> const \fBACE_Time_Value\fR & ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_time (void) const\fC [virtual]\fR
.PP
Returns the time of the earlier node in the . Must be called on a non-empty queue.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (const \fBACE_Time_Value\fR & current_time)\fC [virtual]\fR
.PP
Run the <functor> for all timers whose values are <= <cur_time>. This does not account for <timer_skew>. Returns the number of timers canceled. 
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::expire (void)\fC [virtual]\fR
.PP
Run the <functor> for all timers whose values are <= . Also accounts for <timer_skew>. Returns the number of timers canceled.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> \fBACE_Timer_Node_T\fR< TYPE >* ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::get_first (void)\fC [virtual]\fR
.PP
Reads the earliest node from the queue and returns it.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::is_empty (void) const\fC [virtual]\fR
.PP
True if queue is empty, else false.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> \fBACE_Timer_Queue_Iterator_T\fR< TYPE,FUNCTOR,ACE_LOCK >& ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::iter (void)\fC [virtual]\fR
.PP
Returns a pointer to this 's iterator.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> void ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::operator= (const ACE_Timer_Wheel_T< TYPE,FUNCTOR,ACE_LOCK >&)\fC [private]\fR
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> \fBACE_Timer_Node_T\fR< TYPE >* ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::remove_first (void)\fC [virtual]\fR
.PP
Removes the earliest node from the queue and returns it.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> void ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (\fBACE_Timer_Node_T\fR< TYPE >*)\fC [private, virtual]\fR
.PP
Reschedule an "interval" node.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> int ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::reset_interval (long timer_id, const \fBACE_Time_Value\fR & interval)\fC [virtual]\fR
.PP
Changes the interval of a timer (and can make it periodic or non periodic by setting it to \fBACE_Time_Value::zero\fR or not).
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> long ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE & type, const void * act, const \fBACE_Time_Value\fR & delay, const \fBACE_Time_Value\fR & interval = \fBACE_Time_Value::zero\fR)\fC [virtual]\fR
.PP
Schedules a timer.
.PP
Reimplemented from \fBACE_Timer_Queue_T\fR.
.SH FRIENDS AND RELATED FUNCTION DOCUMENTATION
.PP 
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> class \fBACE_Timer_Wheel_Iterator_T\fR\fC [friend]\fR
.PP
Iterator is a friend.
.PP
.SH MEMBER DATA DOCUMENTATION
.PP 
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> size_t ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::earliest_pos_\fC [private]\fR
.PP
Index of the list with the earliest time.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> \fBACE_Timer_Node_T\fR< TYPE >* ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::freelist_\fC [private]\fR
.PP
Pointer to the freelist of >.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> \fBWHEEL_ITERATOR\fR * ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::iterator_\fC [private]\fR
.PP
Iterator used to expire timers.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> size_t ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::resolution_\fC [private]\fR
.PP
Resolution (in microsoconds) of the timing wheel.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> long ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::size_\fC [private]\fR
.PP
Keeps track of the size of the queue.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> \fBACE_Timer_Node_T\fR< TYPE >** ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::wheel_\fC [private]\fR
.PP
Timing Wheel.
.PP
.SS template<classTYPE, classFUNCTOR, classACE_LOCK> size_t ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::wheel_size_\fC [private]\fR
.PP
Size of the timing wheel.
.PP


.SH AUTHOR
.PP 
Generated automatically by Doxygen for ACE from the source code.