… | |
… | |
29 | { |
29 | { |
30 | ev_idle_stop (w); |
30 | ev_idle_stop (w); |
31 | } |
31 | } |
32 | |
32 | |
33 | static void |
33 | static void |
34 | prepare_cb (struct ev_watcher *w, int revents) |
34 | prepare_cb (struct ev_prepare *w, int revents) |
35 | { |
35 | { |
|
|
36 | static int incede; |
|
|
37 | |
|
|
38 | ++incede; |
|
|
39 | |
|
|
40 | CORO_CEDE_NOTSELF; |
|
|
41 | |
36 | while (CORO_NREADY && CORO_CEDE) |
42 | while (CORO_NREADY > incede && CORO_CEDE) |
37 | ; |
43 | ; |
38 | |
44 | |
39 | /* if still ready, then we have lower-priority coroutines. |
45 | /* if still ready, then we have lower-priority coroutines. |
40 | * cede once, then poll nonblocking |
46 | * poll anyways, but do not block. |
41 | */ |
47 | */ |
42 | if (CORO_NREADY) |
48 | if (CORO_NREADY > incede && !ev_is_active (&idler)) |
43 | { |
49 | ev_idle_start (&idler); |
44 | CORO_CEDE_NOTSELF; |
|
|
45 | |
50 | |
46 | if (CORO_NREADY) |
51 | --incede; |
47 | ev_idle_start (&idler); |
|
|
48 | } |
|
|
49 | } |
52 | } |
50 | |
53 | |
51 | MODULE = Coro::EV PACKAGE = Coro::EV |
54 | MODULE = Coro::EV PACKAGE = Coro::EV |
52 | |
55 | |
53 | PROTOTYPES: ENABLE |
56 | PROTOTYPES: ENABLE |