… | |
… | |
1736 | void |
1736 | void |
1737 | ev_loop_destroy (EV_P) |
1737 | ev_loop_destroy (EV_P) |
1738 | { |
1738 | { |
1739 | int i; |
1739 | int i; |
1740 | |
1740 | |
|
|
1741 | /* mimic free (0) */ |
|
|
1742 | if (!EV_A) |
|
|
1743 | return; |
|
|
1744 | |
1741 | #if EV_CLEANUP_ENABLE |
1745 | #if EV_CLEANUP_ENABLE |
1742 | /* queue cleanup watchers (and execute them) */ |
1746 | /* queue cleanup watchers (and execute them) */ |
1743 | if (expect_false (cleanupcnt)) |
1747 | if (expect_false (cleanupcnt)) |
1744 | { |
1748 | { |
1745 | queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP); |
1749 | queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP); |
… | |
… | |
3592 | |
3596 | |
3593 | ev_start (EV_A_ (W)w, ++cleanupcnt); |
3597 | ev_start (EV_A_ (W)w, ++cleanupcnt); |
3594 | array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); |
3598 | array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); |
3595 | cleanups [cleanupcnt - 1] = w; |
3599 | cleanups [cleanupcnt - 1] = w; |
3596 | |
3600 | |
|
|
3601 | /* cleanup watchers should never keep a refcount on the loop */ |
|
|
3602 | ev_unref (EV_A); |
3597 | EV_FREQUENT_CHECK; |
3603 | EV_FREQUENT_CHECK; |
3598 | } |
3604 | } |
3599 | |
3605 | |
3600 | void |
3606 | void |
3601 | ev_cleanup_stop (EV_P_ ev_cleanup *w) |
3607 | ev_cleanup_stop (EV_P_ ev_cleanup *w) |
… | |
… | |
3603 | clear_pending (EV_A_ (W)w); |
3609 | clear_pending (EV_A_ (W)w); |
3604 | if (expect_false (!ev_is_active (w))) |
3610 | if (expect_false (!ev_is_active (w))) |
3605 | return; |
3611 | return; |
3606 | |
3612 | |
3607 | EV_FREQUENT_CHECK; |
3613 | EV_FREQUENT_CHECK; |
|
|
3614 | ev_ref (EV_A); |
3608 | |
3615 | |
3609 | { |
3616 | { |
3610 | int active = ev_active (w); |
3617 | int active = ev_active (w); |
3611 | |
3618 | |
3612 | cleanups [active - 1] = cleanups [--cleanupcnt]; |
3619 | cleanups [active - 1] = cleanups [--cleanupcnt]; |