… | |
… | |
23 | *stash_timer, |
23 | *stash_timer, |
24 | *stash_periodic, |
24 | *stash_periodic, |
25 | *stash_signal, |
25 | *stash_signal, |
26 | *stash_idle, |
26 | *stash_idle, |
27 | *stash_prepare, |
27 | *stash_prepare, |
28 | *stash_check; |
28 | *stash_check, |
|
|
29 | *stash_child; |
29 | |
30 | |
30 | static int |
31 | static int |
31 | sv_signum (SV *sig) |
32 | sv_signum (SV *sig) |
32 | { |
33 | { |
33 | int signum; |
34 | int signum; |
… | |
… | |
103 | static void |
104 | static void |
104 | e_cb (struct ev_watcher *w, int revents) |
105 | e_cb (struct ev_watcher *w, int revents) |
105 | { |
106 | { |
106 | dSP; |
107 | dSP; |
107 | I32 mark = SP - PL_stack_base; |
108 | I32 mark = SP - PL_stack_base; |
108 | SV *sv_self, *sv_events; |
109 | SV *sv_self, *sv_events, *sv_status = 0; |
109 | static SV *sv_events_cache; |
110 | static SV *sv_events_cache; |
110 | |
111 | |
111 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
112 | sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ |
112 | |
113 | |
113 | if (sv_events_cache) |
114 | if (sv_events_cache) |
… | |
… | |
120 | |
121 | |
121 | PUSHMARK (SP); |
122 | PUSHMARK (SP); |
122 | EXTEND (SP, 2); |
123 | EXTEND (SP, 2); |
123 | PUSHs (sv_self); |
124 | PUSHs (sv_self); |
124 | PUSHs (sv_events); |
125 | PUSHs (sv_events); |
|
|
126 | |
|
|
127 | if (revents & EV_CHILD) |
|
|
128 | XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); |
|
|
129 | |
125 | PUTBACK; |
130 | PUTBACK; |
126 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
131 | call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); |
127 | SP = PL_stack_base + mark; PUTBACK; |
132 | SP = PL_stack_base + mark; PUTBACK; |
128 | |
133 | |
129 | SvREFCNT_dec (sv_self); |
134 | SvREFCNT_dec (sv_self); |
|
|
135 | SvREFCNT_dec (sv_status); |
130 | |
136 | |
131 | if (sv_events_cache) |
137 | if (sv_events_cache) |
132 | SvREFCNT_dec (sv_events); |
138 | SvREFCNT_dec (sv_events); |
133 | else |
139 | else |
134 | sv_events_cache = sv_events; |
140 | sv_events_cache = sv_events; |
… | |
… | |
244 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
250 | stash_periodic = gv_stashpv ("EV::Periodic", 1); |
245 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
251 | stash_signal = gv_stashpv ("EV::Signal" , 1); |
246 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
252 | stash_idle = gv_stashpv ("EV::Idle" , 1); |
247 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
253 | stash_prepare = gv_stashpv ("EV::Prepare" , 1); |
248 | stash_check = gv_stashpv ("EV::Check" , 1); |
254 | stash_check = gv_stashpv ("EV::Check" , 1); |
|
|
255 | stash_child = gv_stashpv ("EV::Child" , 1); |
249 | |
256 | |
250 | { |
257 | { |
251 | SV *sv = perl_get_sv ("EV::API", TRUE); |
258 | SV *sv = perl_get_sv ("EV::API", TRUE); |
252 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
259 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
253 | |
260 | |
… | |
… | |
275 | evapi.idle_stop = evidle_stop; |
282 | evapi.idle_stop = evidle_stop; |
276 | evapi.prepare_start = evprepare_start; |
283 | evapi.prepare_start = evprepare_start; |
277 | evapi.prepare_stop = evprepare_stop; |
284 | evapi.prepare_stop = evprepare_stop; |
278 | evapi.check_start = evcheck_start; |
285 | evapi.check_start = evcheck_start; |
279 | evapi.check_stop = evcheck_stop; |
286 | evapi.check_stop = evcheck_stop; |
|
|
287 | evapi.child_start = evchild_start; |
|
|
288 | evapi.child_stop = evchild_stop; |
280 | |
289 | |
281 | sv_setiv (sv, (IV)&evapi); |
290 | sv_setiv (sv, (IV)&evapi); |
282 | SvREADONLY_on (sv); |
291 | SvREADONLY_on (sv); |
283 | } |
292 | } |
284 | } |
293 | } |
… | |
… | |
378 | evcheck_set (RETVAL); |
387 | evcheck_set (RETVAL); |
379 | if (!ix) evcheck_start (RETVAL); |
388 | if (!ix) evcheck_start (RETVAL); |
380 | OUTPUT: |
389 | OUTPUT: |
381 | RETVAL |
390 | RETVAL |
382 | |
391 | |
|
|
392 | struct ev_child *child (SV *cb, int pid) |
|
|
393 | ALIAS: |
|
|
394 | check_ns = 1 |
|
|
395 | CODE: |
|
|
396 | RETVAL = e_new (sizeof (struct ev_check), cb); |
|
|
397 | evchild_set (RETVAL, pid); |
|
|
398 | if (!ix) evchild_start (RETVAL); |
|
|
399 | OUTPUT: |
|
|
400 | RETVAL |
|
|
401 | |
383 | |
402 | |
384 | PROTOTYPES: DISABLE |
403 | PROTOTYPES: DISABLE |
385 | |
404 | |
386 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
405 | MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ |
387 | |
406 | |
… | |
… | |
529 | MODULE = EV PACKAGE = EV::Check PREFIX = evcheck_ |
548 | MODULE = EV PACKAGE = EV::Check PREFIX = evcheck_ |
530 | |
549 | |
531 | void evcheck_start (struct ev_check *w) |
550 | void evcheck_start (struct ev_check *w) |
532 | |
551 | |
533 | void evcheck_stop (struct ev_check *w) |
552 | void evcheck_stop (struct ev_check *w) |
|
|
553 | |
|
|
554 | MODULE = EV PACKAGE = EV::Child PREFIX = evchild_ |
|
|
555 | |
|
|
556 | void evchild_start (struct ev_child *w) |
|
|
557 | |
|
|
558 | void evchild_stop (struct ev_child *w) |
|
|
559 | |
|
|
560 | void set (struct ev_child *w, int pid) |
|
|
561 | CODE: |
|
|
562 | { |
|
|
563 | int active = w->active; |
|
|
564 | if (active) evchild_stop (w); |
|
|
565 | evchild_set (w, pid); |
|
|
566 | if (active) evchild_start (w); |
|
|
567 | } |
|
|
568 | |
|
|
569 | int status (struct ev_child *w) |
|
|
570 | CODE: |
|
|
571 | RETVAL = w->status; |
|
|
572 | OUTPUT: |
|
|
573 | RETVAL |
534 | |
574 | |
535 | #if 0 |
575 | #if 0 |
536 | |
576 | |
537 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
577 | MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_ |
538 | |
578 | |