File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ class Timer {
134
134
repeat; /* repeat task */
135
135
} tasks[max_tasks];
136
136
137
+ unsigned long id_counter = 1 ;
138
+
137
139
inline
138
140
void
139
141
remove (struct task *task)
@@ -158,6 +160,14 @@ class Timer {
158
160
return NULL ;
159
161
}
160
162
163
+ unsigned long next_task_id () {
164
+
165
+ unsigned long id = id_counter;
166
+ id_counter++;
167
+
168
+ return id;
169
+ }
170
+
161
171
inline
162
172
struct task *
163
173
add_task (unsigned long start, unsigned long expires,
@@ -166,10 +176,10 @@ class Timer {
166
176
struct task * const slot = next_task_slot ();
167
177
168
178
if (!slot)
169
- slot->id = random ( 2147483646 );
179
+ slot->id = 0 ;
170
180
else
171
- slot->id = 0 ;
172
-
181
+ slot->id = next_task_id (); // random(2147483646) ;
182
+
173
183
slot->handler = h;
174
184
slot->opaque = opaque;
175
185
slot->start = start;
You can’t perform that action at this time.
0 commit comments