Browse code

core: renamed cycles to loops to reflect rotation of the wheel timer

Daniel-Constantin Mierla authored on 25/01/2016 22:37:49
Showing 1 changed files
... ...
@@ -278,13 +278,14 @@ int fork_sync_utimer(int child_id, char* desc, int make_sock,
278 278
 }
279 279
 
280 280
 
281
+/* number of slots in the wheel timer */
281 282
 #define SR_WTIMER_SIZE	16
282 283
 
283 284
 typedef struct sr_wtimer_node {
284 285
 	struct sr_wtimer_node *next;
285
-	uint32_t interval;
286
-	uint32_t steps;
287
-	uint32_t cycles;
286
+	uint32_t interval;  /* frequency of execution (secs) */
287
+	uint32_t steps;     /* interval = loops * SR_WTIMER_SIZE + steps */
288
+	uint32_t loops;
288 289
 	timer_function* f;
289 290
 	void* param;
290 291
 } sr_wtimer_node_t;
... ...
@@ -335,7 +336,7 @@ int sr_wtimer_add(timer_function* f, void* param, int interval)
335 336
 	wt->param = param;
336 337
 	wt->interval = interval;
337 338
 	wt->steps = interval % SR_WTIMER_SIZE;
338
-	wt->cycles = interval / SR_WTIMER_SIZE;
339
+	wt->loops = interval / SR_WTIMER_SIZE;
339 340
 	wt->next = _sr_wtimer->wlist[wt->steps];
340 341
 	_sr_wtimer->wlist[wt->steps] = wt;
341 342
 
... ...
@@ -363,7 +364,7 @@ void sr_wtimer_exec(unsigned int ticks, void *param)
363 364
 		if(_sr_wtimer->itimer % i == 0) {
364 365
 			for(wt=_sr_wtimer->wlist[i % SR_WTIMER_SIZE];
365 366
 					wt!=NULL; wt = wt->next) {
366
-				if(wt->cycles==0 || (c % wt->cycles==0)) {
367
+				if(wt->loops==0 || (c % wt->loops==0)) {
367 368
 					wt->f(ticks, wt->param);
368 369
 				}
369 370
 			}