… | |
… | |
120 | *stash_idle, |
120 | *stash_idle, |
121 | *stash_prepare, |
121 | *stash_prepare, |
122 | *stash_check, |
122 | *stash_check, |
123 | *stash_embed, |
123 | *stash_embed, |
124 | *stash_fork, |
124 | *stash_fork, |
|
|
125 | *stash_cleanup, |
125 | *stash_async; |
126 | *stash_async; |
126 | |
127 | |
127 | ///////////////////////////////////////////////////////////////////////////// |
128 | ///////////////////////////////////////////////////////////////////////////// |
128 | // Event |
129 | // Event |
129 | |
130 | |
… | |
… | |
207 | |
208 | |
208 | if (expect_true (sv_events_cache)) |
209 | if (expect_true (sv_events_cache)) |
209 | { |
210 | { |
210 | sv_events = sv_events_cache; sv_events_cache = 0; |
211 | sv_events = sv_events_cache; sv_events_cache = 0; |
211 | SvIV_set (sv_events, revents); |
212 | SvIV_set (sv_events, revents); |
|
|
213 | SvIOK_only (sv_events); |
212 | } |
214 | } |
213 | else |
215 | else |
214 | { |
216 | { |
215 | sv_events = newSViv (revents); |
217 | sv_events = newSViv (revents); |
216 | SvREADONLY_on (sv_events); |
218 | SvREADONLY_on (sv_events); |
… | |
… | |
340 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
342 | croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); |
341 | |
343 | |
342 | #define CHECK_SIG(sv,num) if ((num) < 0) \ |
344 | #define CHECK_SIG(sv,num) if ((num) < 0) \ |
343 | croak ("illegal signal number or name: %s", SvPV_nolen (sv)); |
345 | croak ("illegal signal number or name: %s", SvPV_nolen (sv)); |
344 | |
346 | |
|
|
347 | static void |
|
|
348 | default_fork (void) |
|
|
349 | { |
|
|
350 | ev_loop_fork (EV_DEFAULT_UC); |
|
|
351 | } |
|
|
352 | |
345 | ///////////////////////////////////////////////////////////////////////////// |
353 | ///////////////////////////////////////////////////////////////////////////// |
346 | // XS interface functions |
354 | // XS interface functions |
347 | |
355 | |
348 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
356 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
349 | |
357 | |
… | |
… | |
364 | const_iv (EV_, UNDEF) |
372 | const_iv (EV_, UNDEF) |
365 | const_iv (EV_, NONE) |
373 | const_iv (EV_, NONE) |
366 | const_iv (EV_, READ) |
374 | const_iv (EV_, READ) |
367 | const_iv (EV_, WRITE) |
375 | const_iv (EV_, WRITE) |
368 | const_iv (EV_, IO) |
376 | const_iv (EV_, IO) |
369 | const_iv (EV_, TIMEOUT) |
377 | const_iv (EV_, TIMER) |
370 | const_iv (EV_, PERIODIC) |
378 | const_iv (EV_, PERIODIC) |
371 | const_iv (EV_, SIGNAL) |
379 | const_iv (EV_, SIGNAL) |
372 | const_iv (EV_, CHILD) |
380 | const_iv (EV_, CHILD) |
373 | const_iv (EV_, STAT) |
381 | const_iv (EV_, STAT) |
374 | const_iv (EV_, IDLE) |
382 | const_iv (EV_, IDLE) |
375 | const_iv (EV_, PREPARE) |
383 | const_iv (EV_, PREPARE) |
376 | const_iv (EV_, CHECK) |
384 | const_iv (EV_, CHECK) |
377 | const_iv (EV_, EMBED) |
385 | const_iv (EV_, EMBED) |
378 | const_iv (EV_, FORK) |
386 | const_iv (EV_, FORK) |
|
|
387 | const_iv (EV_, CLEANUP) |
379 | const_iv (EV_, ASYNC) |
388 | const_iv (EV_, ASYNC) |
380 | const_iv (EV_, CUSTOM) |
389 | const_iv (EV_, CUSTOM) |
381 | const_iv (EV_, ERROR) |
390 | const_iv (EV_, ERROR) |
382 | |
391 | |
383 | const_iv (EV, RUN_NOWAIT) |
392 | const_iv (EV, RUN_NOWAIT) |
… | |
… | |
395 | const_iv (EV, BACKEND_ALL) |
404 | const_iv (EV, BACKEND_ALL) |
396 | const_iv (EV, FLAG_AUTO) |
405 | const_iv (EV, FLAG_AUTO) |
397 | const_iv (EV, FLAG_FORKCHECK) |
406 | const_iv (EV, FLAG_FORKCHECK) |
398 | const_iv (EV, FLAG_SIGNALFD) |
407 | const_iv (EV, FLAG_SIGNALFD) |
399 | const_iv (EV, FLAG_NOENV) |
408 | const_iv (EV, FLAG_NOENV) |
400 | const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ |
|
|
401 | const_iv (EV, FLAG_NOINOTIFY) |
409 | const_iv (EV, FLAG_NOINOTIFY) |
402 | |
410 | |
403 | const_iv (EV_, VERSION_MAJOR) |
411 | const_iv (EV_, VERSION_MAJOR) |
404 | const_iv (EV_, VERSION_MINOR) |
412 | const_iv (EV_, VERSION_MINOR) |
405 | #if EV_COMPAT3 |
413 | #if EV_COMPAT3 |
|
|
414 | const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ |
406 | const_iv (EV_, TIMER) |
415 | const_iv (EV_, TIMEOUT) |
407 | |
|
|
408 | const_iv (EV, LOOP_NONBLOCK) |
416 | const_iv (EV, LOOP_NONBLOCK) |
409 | const_iv (EV, LOOP_ONESHOT) |
417 | const_iv (EV, LOOP_ONESHOT) |
410 | |
|
|
411 | const_iv (EV, UNLOOP_CANCEL) |
418 | const_iv (EV, UNLOOP_CANCEL) |
412 | const_iv (EV, UNLOOP_ONE) |
419 | const_iv (EV, UNLOOP_ONE) |
413 | const_iv (EV, UNLOOP_ALL) |
420 | const_iv (EV, UNLOOP_ALL) |
414 | #endif |
421 | #endif |
415 | }; |
422 | }; |
… | |
… | |
428 | stash_check = gv_stashpv ("EV::Check" , 1); |
435 | stash_check = gv_stashpv ("EV::Check" , 1); |
429 | stash_child = gv_stashpv ("EV::Child" , 1); |
436 | stash_child = gv_stashpv ("EV::Child" , 1); |
430 | stash_embed = gv_stashpv ("EV::Embed" , 1); |
437 | stash_embed = gv_stashpv ("EV::Embed" , 1); |
431 | stash_stat = gv_stashpv ("EV::Stat" , 1); |
438 | stash_stat = gv_stashpv ("EV::Stat" , 1); |
432 | stash_fork = gv_stashpv ("EV::Fork" , 1); |
439 | stash_fork = gv_stashpv ("EV::Fork" , 1); |
|
|
440 | stash_cleanup = gv_stashpv ("EV::Cleanup" , 1); |
433 | stash_async = gv_stashpv ("EV::Async" , 1); |
441 | stash_async = gv_stashpv ("EV::Async" , 1); |
434 | |
442 | |
435 | { |
443 | { |
436 | SV *sv = perl_get_sv ("EV::API", TRUE); |
444 | SV *sv = perl_get_sv ("EV::API", TRUE); |
437 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
445 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
… | |
… | |
494 | evapi.embed_start = ev_embed_start; |
502 | evapi.embed_start = ev_embed_start; |
495 | evapi.embed_stop = ev_embed_stop; |
503 | evapi.embed_stop = ev_embed_stop; |
496 | evapi.embed_sweep = ev_embed_sweep; |
504 | evapi.embed_sweep = ev_embed_sweep; |
497 | evapi.fork_start = ev_fork_start; |
505 | evapi.fork_start = ev_fork_start; |
498 | evapi.fork_stop = ev_fork_stop; |
506 | evapi.fork_stop = ev_fork_stop; |
|
|
507 | evapi.cleanup_start = ev_cleanup_start; |
|
|
508 | evapi.cleanup_stop = ev_cleanup_stop; |
499 | evapi.async_start = ev_async_start; |
509 | evapi.async_start = ev_async_start; |
500 | evapi.async_stop = ev_async_stop; |
510 | evapi.async_stop = ev_async_stop; |
501 | evapi.async_send = ev_async_send; |
511 | evapi.async_send = ev_async_send; |
502 | evapi.clear_pending = ev_clear_pending; |
512 | evapi.clear_pending = ev_clear_pending; |
503 | evapi.invoke = ev_invoke; |
513 | evapi.invoke = ev_invoke; |
504 | |
514 | |
505 | sv_setiv (sv, (IV)&evapi); |
515 | sv_setiv (sv, (IV)&evapi); |
506 | SvREADONLY_on (sv); |
516 | SvREADONLY_on (sv); |
507 | } |
517 | } |
508 | #if !defined(_WIN32) && !defined(_MINIX) |
518 | #if !defined(_WIN32) && !defined(_MINIX) |
509 | pthread_atfork (0, 0, ev_default_fork); |
519 | pthread_atfork (0, 0, default_fork); |
510 | #endif |
520 | #endif |
511 | } |
521 | } |
512 | |
522 | |
513 | SV *ev_default_loop (unsigned int flags = 0) |
523 | SV *ev_default_loop (unsigned int flags = 0) |
514 | CODE: |
524 | CODE: |
… | |
… | |
713 | ev_fork_set (RETVAL); |
723 | ev_fork_set (RETVAL); |
714 | if (!ix) START (fork, RETVAL); |
724 | if (!ix) START (fork, RETVAL); |
715 | OUTPUT: |
725 | OUTPUT: |
716 | RETVAL |
726 | RETVAL |
717 | |
727 | |
|
|
728 | ev_cleanup *cleanup (SV *cb) |
|
|
729 | ALIAS: |
|
|
730 | cleanup_ns = 1 |
|
|
731 | CODE: |
|
|
732 | RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv); |
|
|
733 | ev_cleanup_set (RETVAL); |
|
|
734 | if (!ix) START (cleanup, RETVAL); |
|
|
735 | OUTPUT: |
|
|
736 | RETVAL |
718 | |
737 | |
719 | ev_child *child (int pid, int trace, SV *cb) |
738 | ev_child *child (int pid, int trace, SV *cb) |
720 | ALIAS: |
739 | ALIAS: |
721 | child_ns = 1 |
740 | child_ns = 1 |
722 | CODE: |
741 | CODE: |
… | |
… | |
740 | ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval); |
759 | ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval); |
741 | if (!ix) START (stat, RETVAL); |
760 | if (!ix) START (stat, RETVAL); |
742 | OUTPUT: |
761 | OUTPUT: |
743 | RETVAL |
762 | RETVAL |
744 | |
763 | |
|
|
764 | #ifndef EV_NO_LOOPS |
|
|
765 | |
745 | ev_embed *embed (struct ev_loop *loop, SV *cb = 0) |
766 | ev_embed *embed (struct ev_loop *loop, SV *cb = 0) |
746 | ALIAS: |
767 | ALIAS: |
747 | embed_ns = 1 |
768 | embed_ns = 1 |
748 | CODE: |
769 | CODE: |
749 | { |
770 | { |
… | |
… | |
755 | ev_embed_set (RETVAL, loop); |
776 | ev_embed_set (RETVAL, loop); |
756 | if (!ix) START (embed, RETVAL); |
777 | if (!ix) START (embed, RETVAL); |
757 | } |
778 | } |
758 | OUTPUT: |
779 | OUTPUT: |
759 | RETVAL |
780 | RETVAL |
|
|
781 | |
|
|
782 | #endif |
760 | |
783 | |
761 | ev_async *async (SV *cb) |
784 | ev_async *async (SV *cb) |
762 | ALIAS: |
785 | ALIAS: |
763 | async_ns = 1 |
786 | async_ns = 1 |
764 | CODE: |
787 | CODE: |
… | |
… | |
1102 | |
1125 | |
1103 | void DESTROY (ev_fork *w) |
1126 | void DESTROY (ev_fork *w) |
1104 | CODE: |
1127 | CODE: |
1105 | STOP (fork, w); |
1128 | STOP (fork, w); |
1106 | e_destroy (w); |
1129 | e_destroy (w); |
|
|
1130 | |
|
|
1131 | MODULE = EV PACKAGE = EV::Cleanup PREFIX = ev_cleanup_ |
|
|
1132 | |
|
|
1133 | void ev_cleanup_start (ev_cleanup *w) |
|
|
1134 | CODE: |
|
|
1135 | START (cleanup, w); |
|
|
1136 | |
|
|
1137 | void ev_cleanup_stop (ev_cleanup *w) |
|
|
1138 | CODE: |
|
|
1139 | STOP (cleanup, w); |
|
|
1140 | |
|
|
1141 | void DESTROY (ev_cleanup *w) |
|
|
1142 | CODE: |
|
|
1143 | STOP (cleanup, w); |
|
|
1144 | e_destroy (w); |
|
|
1145 | |
|
|
1146 | int keepalive (ev_watcher *w, int new_value = 0) |
|
|
1147 | CODE: |
|
|
1148 | RETVAL = 0; |
|
|
1149 | OUTPUT: |
|
|
1150 | RETVAL |
1107 | |
1151 | |
1108 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1152 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1109 | |
1153 | |
1110 | #if EV_CHILD_ENABLE |
1154 | #if EV_CHILD_ENABLE |
1111 | |
1155 | |
… | |
… | |
1286 | CODE: |
1330 | CODE: |
1287 | RETVAL = boolSV (ev_async_pending (w)); |
1331 | RETVAL = boolSV (ev_async_pending (w)); |
1288 | OUTPUT: |
1332 | OUTPUT: |
1289 | RETVAL |
1333 | RETVAL |
1290 | |
1334 | |
|
|
1335 | #ifndef EV_NO_LOOPS |
|
|
1336 | |
1291 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ |
1337 | MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ |
1292 | |
1338 | |
1293 | SV *new (SV *klass, unsigned int flags = 0) |
1339 | SV *new (SV *klass, unsigned int flags = 0) |
1294 | CODE: |
1340 | CODE: |
1295 | { |
1341 | { |
… | |
… | |
1463 | ev_fork_set (RETVAL); |
1509 | ev_fork_set (RETVAL); |
1464 | if (!ix) START (fork, RETVAL); |
1510 | if (!ix) START (fork, RETVAL); |
1465 | OUTPUT: |
1511 | OUTPUT: |
1466 | RETVAL |
1512 | RETVAL |
1467 | |
1513 | |
|
|
1514 | ev_cleanup *cleanup (struct ev_loop *loop, SV *cb) |
|
|
1515 | ALIAS: |
|
|
1516 | cleanup_ns = 1 |
|
|
1517 | CODE: |
|
|
1518 | RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0)); |
|
|
1519 | ev_cleanup_set (RETVAL); |
|
|
1520 | if (!ix) START (cleanup, RETVAL); |
|
|
1521 | OUTPUT: |
|
|
1522 | RETVAL |
1468 | |
1523 | |
1469 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
1524 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
1470 | ALIAS: |
1525 | ALIAS: |
1471 | child_ns = 1 |
1526 | child_ns = 1 |
1472 | CODE: |
1527 | CODE: |
… | |
… | |
1525 | SvOK (timeout) ? SvNV (timeout) : -1., |
1580 | SvOK (timeout) ? SvNV (timeout) : -1., |
1526 | e_once_cb, |
1581 | e_once_cb, |
1527 | newSVsv (cb) |
1582 | newSVsv (cb) |
1528 | ); |
1583 | ); |
1529 | |
1584 | |
|
|
1585 | #endif |
|
|
1586 | |