… | |
… | |
233 | #if EV_MULTIPLICITY |
233 | #if EV_MULTIPLICITY |
234 | |
234 | |
235 | struct ev_loop |
235 | struct ev_loop |
236 | { |
236 | { |
237 | ev_tstamp ev_rt_now; |
237 | ev_tstamp ev_rt_now; |
|
|
238 | #define ev_rt_now ((loop)->ev_rt_now) |
238 | #define VAR(name,decl) decl; |
239 | #define VAR(name,decl) decl; |
239 | #include "ev_vars.h" |
240 | #include "ev_vars.h" |
240 | #undef VAR |
241 | #undef VAR |
241 | }; |
242 | }; |
242 | #include "ev_wrap.h" |
243 | #include "ev_wrap.h" |
… | |
… | |
534 | heap [k] = w; |
535 | heap [k] = w; |
535 | ((W)heap [k])->active = k + 1; |
536 | ((W)heap [k])->active = k + 1; |
536 | } |
537 | } |
537 | |
538 | |
538 | inline void |
539 | inline void |
539 | adjustheap (WT *heap, int N, int k, ev_tstamp at) |
540 | adjustheap (WT *heap, int N, int k) |
540 | { |
541 | { |
541 | ev_tstamp old_at = heap [k]->at; |
542 | upheap (heap, k); |
542 | heap [k]->at = at; |
|
|
543 | |
|
|
544 | if (old_at < at) |
|
|
545 | downheap (heap, N, k); |
543 | downheap (heap, N, k); |
546 | else |
|
|
547 | upheap (heap, k); |
|
|
548 | } |
544 | } |
549 | |
545 | |
550 | /*****************************************************************************/ |
546 | /*****************************************************************************/ |
551 | |
547 | |
552 | typedef struct |
548 | typedef struct |
… | |
… | |
1352 | assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); |
1348 | assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); |
1353 | |
1349 | |
1354 | if (((W)w)->active < timercnt--) |
1350 | if (((W)w)->active < timercnt--) |
1355 | { |
1351 | { |
1356 | timers [((W)w)->active - 1] = timers [timercnt]; |
1352 | timers [((W)w)->active - 1] = timers [timercnt]; |
1357 | downheap ((WT *)timers, timercnt, ((W)w)->active - 1); |
1353 | adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1); |
1358 | } |
1354 | } |
1359 | |
1355 | |
1360 | ((WT)w)->at -= mn_now; |
1356 | ((WT)w)->at -= mn_now; |
1361 | |
1357 | |
1362 | ev_stop (EV_A_ (W)w); |
1358 | ev_stop (EV_A_ (W)w); |
… | |
… | |
1366 | ev_timer_again (EV_P_ struct ev_timer *w) |
1362 | ev_timer_again (EV_P_ struct ev_timer *w) |
1367 | { |
1363 | { |
1368 | if (ev_is_active (w)) |
1364 | if (ev_is_active (w)) |
1369 | { |
1365 | { |
1370 | if (w->repeat) |
1366 | if (w->repeat) |
|
|
1367 | { |
|
|
1368 | ((WT)w)->at = mn_now + w->repeat; |
1371 | adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1, mn_now + w->repeat); |
1369 | adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1); |
|
|
1370 | } |
1372 | else |
1371 | else |
1373 | ev_timer_stop (EV_A_ w); |
1372 | ev_timer_stop (EV_A_ w); |
1374 | } |
1373 | } |
1375 | else if (w->repeat) |
1374 | else if (w->repeat) |
1376 | ev_timer_start (EV_A_ w); |
1375 | ev_timer_start (EV_A_ w); |
… | |
… | |
1410 | assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); |
1409 | assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); |
1411 | |
1410 | |
1412 | if (((W)w)->active < periodiccnt--) |
1411 | if (((W)w)->active < periodiccnt--) |
1413 | { |
1412 | { |
1414 | periodics [((W)w)->active - 1] = periodics [periodiccnt]; |
1413 | periodics [((W)w)->active - 1] = periodics [periodiccnt]; |
1415 | downheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1); |
1414 | adjustheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1); |
1416 | } |
1415 | } |
1417 | |
1416 | |
1418 | ev_stop (EV_A_ (W)w); |
1417 | ev_stop (EV_A_ (W)w); |
1419 | } |
1418 | } |
1420 | |
1419 | |