… | |
… | |
21 | #define ONCE_INIT AV *av = GvAV (PL_defgv); |
21 | #define ONCE_INIT AV *av = GvAV (PL_defgv); |
22 | #define ONCE_DONE av_clear (av); av_push (av, SvREFCNT_inc (CORO_CURRENT)); |
22 | #define ONCE_DONE av_clear (av); av_push (av, SvREFCNT_inc (CORO_CURRENT)); |
23 | |
23 | |
24 | static struct ev_prepare scheduler; |
24 | static struct ev_prepare scheduler; |
25 | static struct ev_idle idler; |
25 | static struct ev_idle idler; |
|
|
26 | static int inhibit; |
26 | |
27 | |
27 | static void |
28 | static void |
28 | idle_cb (struct ev_idle *w, int revents) |
29 | idle_cb (struct ev_idle *w, int revents) |
29 | { |
30 | { |
30 | ev_idle_stop (w); |
31 | ev_idle_stop (w); |
… | |
… | |
32 | |
33 | |
33 | static void |
34 | static void |
34 | prepare_cb (struct ev_prepare *w, int revents) |
35 | prepare_cb (struct ev_prepare *w, int revents) |
35 | { |
36 | { |
36 | static int incede; |
37 | static int incede; |
|
|
38 | |
|
|
39 | if (inhibit) |
|
|
40 | return; |
37 | |
41 | |
38 | ++incede; |
42 | ++incede; |
39 | |
43 | |
40 | CORO_CEDE_NOTSELF; |
44 | CORO_CEDE_NOTSELF; |
41 | |
45 | |
… | |
… | |
59 | { |
63 | { |
60 | I_EV_API ("Coro::EV"); |
64 | I_EV_API ("Coro::EV"); |
61 | I_CORO_API ("Coro::Event"); |
65 | I_CORO_API ("Coro::Event"); |
62 | |
66 | |
63 | ev_prepare_init (&scheduler, prepare_cb); |
67 | ev_prepare_init (&scheduler, prepare_cb); |
64 | ev_prepare_start (&scheduler); |
68 | ev_prepare_start (EV_DEFAULT_ &scheduler); |
65 | ev_unref (); |
69 | ev_unref (); |
66 | |
70 | |
67 | ev_idle_init (&idler, idle_cb); |
71 | ev_idle_init (&idler, idle_cb); |
68 | } |
72 | } |
|
|
73 | |
|
|
74 | void |
|
|
75 | _loop_oneshot () |
|
|
76 | CODE: |
|
|
77 | ++inhibit; |
|
|
78 | ev_loop (EV_DEFAULT_ EVLOOP_ONESHOT); |
|
|
79 | --inhibit; |
69 | |
80 | |
70 | void |
81 | void |
71 | _timed_io_once (...) |
82 | _timed_io_once (...) |
72 | CODE: |
83 | CODE: |
73 | { |
84 | { |