… | |
… | |
518 | |
518 | |
519 | heap [k] = w; |
519 | heap [k] = w; |
520 | ((W)heap [k])->active = k + 1; |
520 | ((W)heap [k])->active = k + 1; |
521 | } |
521 | } |
522 | |
522 | |
|
|
523 | inline void |
|
|
524 | adjustheap (WT *heap, int N, int k, ev_tstamp at) |
|
|
525 | { |
|
|
526 | ev_tstamp old_at = heap [k]->at; |
|
|
527 | heap [k]->at = at; |
|
|
528 | |
|
|
529 | if (old_at < at) |
|
|
530 | downheap (heap, N, k); |
|
|
531 | else |
|
|
532 | upheap (heap, k); |
|
|
533 | } |
|
|
534 | |
523 | /*****************************************************************************/ |
535 | /*****************************************************************************/ |
524 | |
536 | |
525 | typedef struct |
537 | typedef struct |
526 | { |
538 | { |
527 | WL head; |
539 | WL head; |
… | |
… | |
1321 | ev_timer_again (EV_P_ struct ev_timer *w) |
1333 | ev_timer_again (EV_P_ struct ev_timer *w) |
1322 | { |
1334 | { |
1323 | if (ev_is_active (w)) |
1335 | if (ev_is_active (w)) |
1324 | { |
1336 | { |
1325 | if (w->repeat) |
1337 | if (w->repeat) |
1326 | { |
|
|
1327 | ((WT)w)->at = mn_now + w->repeat; |
|
|
1328 | downheap ((WT *)timers, timercnt, ((W)w)->active - 1); |
1338 | adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1, mn_now + w->repeat); |
1329 | } |
|
|
1330 | else |
1339 | else |
1331 | ev_timer_stop (EV_A_ w); |
1340 | ev_timer_stop (EV_A_ w); |
1332 | } |
1341 | } |
1333 | else if (w->repeat) |
1342 | else if (w->repeat) |
1334 | ev_timer_start (EV_A_ w); |
1343 | ev_timer_start (EV_A_ w); |
… | |
… | |
1376 | } |
1385 | } |
1377 | |
1386 | |
1378 | void |
1387 | void |
1379 | ev_periodic_again (EV_P_ struct ev_periodic *w) |
1388 | ev_periodic_again (EV_P_ struct ev_periodic *w) |
1380 | { |
1389 | { |
|
|
1390 | /* TODO: use adjustheap and recalculation */ |
1381 | ev_periodic_stop (EV_A_ w); |
1391 | ev_periodic_stop (EV_A_ w); |
1382 | ev_periodic_start (EV_A_ w); |
1392 | ev_periodic_start (EV_A_ w); |
1383 | } |
1393 | } |
1384 | |
1394 | |
1385 | void |
1395 | void |