… | |
… | |
15 | return s_fileno (fh, 0); |
15 | return s_fileno (fh, 0); |
16 | } |
16 | } |
17 | |
17 | |
18 | #define EV_STANDALONE 1 |
18 | #define EV_STANDALONE 1 |
19 | #define EV_PROTOTYPES 1 |
19 | #define EV_PROTOTYPES 1 |
20 | #define EV_USE_CLOCK_SYSCALL 0 /* as long as we need pthreads anyways... */ |
|
|
21 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
20 | #define EV_USE_NANOSLEEP EV_USE_MONOTONIC |
22 | #define EV_USE_FLOOR 1 |
21 | #define EV_USE_FLOOR 1 |
23 | #define EV_API_STATIC |
22 | #define EV_API_STATIC |
24 | #define EV_H <ev.h> |
23 | #define EV_H <ev.h> |
25 | #define EV_CONFIG_H error |
24 | #define EV_CONFIG_H error |
… | |
… | |
32 | # define fd_mask Perl_fd_mask |
31 | # define fd_mask Perl_fd_mask |
33 | #endif |
32 | #endif |
34 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
33 | /* due to bugs in OS X we have to use libev/ explicitly here */ |
35 | #include "libev/ev.c" |
34 | #include "libev/ev.c" |
36 | |
35 | |
37 | #if !defined(_WIN32) && !defined(_MINIX) |
36 | #if !defined _WIN32 && !defined _MINIX |
38 | # include <pthread.h> |
37 | # include <pthread.h> |
39 | #endif |
38 | #endif |
40 | |
39 | |
41 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop)) |
40 | #define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop)) |
42 | #define e_flags(w) ((ev_watcher *)(w))->e_flags |
41 | #define e_flags(w) ((ev_watcher *)(w))->e_flags |
… | |
… | |
518 | evapi.invoke = ev_invoke; |
517 | evapi.invoke = ev_invoke; |
519 | |
518 | |
520 | sv_setiv (sv, (IV)&evapi); |
519 | sv_setiv (sv, (IV)&evapi); |
521 | SvREADONLY_on (sv); |
520 | SvREADONLY_on (sv); |
522 | } |
521 | } |
523 | #if !defined(_WIN32) && !defined(_MINIX) |
522 | #if !defined _WIN32 && !defined _MINIX |
|
|
523 | #if __linux |
|
|
524 | int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle); |
|
|
525 | __register_atfork (0, 0, default_fork, 0); |
|
|
526 | #else |
524 | pthread_atfork (0, 0, default_fork); |
527 | pthread_atfork (0, 0, default_fork); |
|
|
528 | #endif |
525 | #endif |
529 | #endif |
526 | } |
530 | } |
527 | |
531 | |
528 | SV *ev_default_loop (unsigned int flags = 0) |
532 | SV *ev_default_loop (unsigned int flags = 0) |
529 | CODE: |
533 | CODE: |
… | |
… | |
602 | C_ARGS: evapi.default_loop, interval |
606 | C_ARGS: evapi.default_loop, interval |
603 | |
607 | |
604 | void ev_set_timeout_collect_interval (NV interval) |
608 | void ev_set_timeout_collect_interval (NV interval) |
605 | C_ARGS: evapi.default_loop, interval |
609 | C_ARGS: evapi.default_loop, interval |
606 | |
610 | |
607 | void ev_run (int flags = 0) |
611 | int ev_run (int flags = 0) |
608 | ALIAS: |
612 | ALIAS: |
609 | loop = 1 |
613 | loop = 1 |
610 | C_ARGS: evapi.default_loop, flags |
614 | C_ARGS: evapi.default_loop, flags |
611 | |
615 | |
612 | void ev_break (int how = EVBREAK_ONE) |
616 | void ev_break (int how = EVBREAK_ONE) |
… | |
… | |
618 | C_ARGS: evapi.default_loop, fd, revents |
622 | C_ARGS: evapi.default_loop, fd, revents |
619 | |
623 | |
620 | void ev_feed_signal_event (SV *signal) |
624 | void ev_feed_signal_event (SV *signal) |
621 | CODE: |
625 | CODE: |
622 | { |
626 | { |
623 | Signal signum = s_signum (signal); |
627 | Signal signum = s_signum (signal); |
624 | CHECK_SIG (signal, signum); |
628 | CHECK_SIG (signal, signum); |
625 | |
629 | |
626 | ev_feed_signal_event (evapi.default_loop, signum); |
630 | ev_feed_signal_event (evapi.default_loop, signum); |
627 | } |
631 | } |
628 | |
632 | |
… | |
… | |
737 | ev_fork_set (RETVAL); |
741 | ev_fork_set (RETVAL); |
738 | if (!ix) START (fork, RETVAL); |
742 | if (!ix) START (fork, RETVAL); |
739 | OUTPUT: |
743 | OUTPUT: |
740 | RETVAL |
744 | RETVAL |
741 | |
745 | |
|
|
746 | #if CLEANUP_ENABLED |
|
|
747 | |
742 | ev_cleanup *cleanup (SV *cb) |
748 | ev_cleanup *cleanup (SV *cb) |
743 | ALIAS: |
749 | ALIAS: |
744 | cleanup_ns = 1 |
750 | cleanup_ns = 1 |
745 | CODE: |
751 | CODE: |
746 | RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv); |
752 | RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv); |
|
|
753 | SvREFCNT_dec (RETVAL->loop); /* must not keep loop object alive */ |
747 | ev_cleanup_set (RETVAL); |
754 | ev_cleanup_set (RETVAL); |
748 | if (!ix) START (cleanup, RETVAL); |
755 | if (!ix) START (cleanup, RETVAL); |
749 | OUTPUT: |
756 | OUTPUT: |
750 | RETVAL |
757 | RETVAL |
|
|
758 | |
|
|
759 | #endif |
751 | |
760 | |
752 | ev_child *child (int pid, int trace, SV *cb) |
761 | ev_child *child (int pid, int trace, SV *cb) |
753 | ALIAS: |
762 | ALIAS: |
754 | child_ns = 1 |
763 | child_ns = 1 |
755 | CODE: |
764 | CODE: |
… | |
… | |
1140 | void DESTROY (ev_fork *w) |
1149 | void DESTROY (ev_fork *w) |
1141 | CODE: |
1150 | CODE: |
1142 | STOP (fork, w); |
1151 | STOP (fork, w); |
1143 | e_destroy (w); |
1152 | e_destroy (w); |
1144 | |
1153 | |
|
|
1154 | #if CLEANUP_ENABLED |
|
|
1155 | |
1145 | MODULE = EV PACKAGE = EV::Cleanup PREFIX = ev_cleanup_ |
1156 | MODULE = EV PACKAGE = EV::Cleanup PREFIX = ev_cleanup_ |
1146 | |
1157 | |
1147 | void ev_cleanup_start (ev_cleanup *w) |
1158 | void ev_cleanup_start (ev_cleanup *w) |
1148 | CODE: |
1159 | CODE: |
1149 | START (cleanup, w); |
1160 | START (cleanup, w); |
… | |
… | |
1153 | STOP (cleanup, w); |
1164 | STOP (cleanup, w); |
1154 | |
1165 | |
1155 | void DESTROY (ev_cleanup *w) |
1166 | void DESTROY (ev_cleanup *w) |
1156 | CODE: |
1167 | CODE: |
1157 | STOP (cleanup, w); |
1168 | STOP (cleanup, w); |
|
|
1169 | SvREFCNT_inc (w->loop); /* has been dec'ed on creation */ |
1158 | e_destroy (w); |
1170 | e_destroy (w); |
1159 | |
1171 | |
1160 | int keepalive (ev_watcher *w, int new_value = 0) |
1172 | int keepalive (ev_watcher *w, SV *new_value = 0) |
1161 | CODE: |
1173 | CODE: |
1162 | RETVAL = 0; |
1174 | RETVAL = 1; |
1163 | OUTPUT: |
1175 | OUTPUT: |
1164 | RETVAL |
1176 | RETVAL |
|
|
1177 | |
|
|
1178 | #endif |
1165 | |
1179 | |
1166 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1180 | MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ |
1167 | |
1181 | |
1168 | #if EV_CHILD_ENABLE |
1182 | #if EV_CHILD_ENABLE |
1169 | |
1183 | |
… | |
… | |
1363 | OUTPUT: |
1377 | OUTPUT: |
1364 | RETVAL |
1378 | RETVAL |
1365 | |
1379 | |
1366 | void DESTROY (struct ev_loop *loop) |
1380 | void DESTROY (struct ev_loop *loop) |
1367 | CODE: |
1381 | CODE: |
1368 | /* 1. the default loop shouldn't be freed by destroying it'S pelr loop object */ |
1382 | /* 1. the default loop shouldn't be freed by destroying it's perl loop object */ |
1369 | /* 2. not doing so helps avoid many global destruction bugs in perl, too */ |
1383 | /* 2. not doing so helps avoid many global destruction bugs in perl, too */ |
1370 | if (loop != evapi.default_loop) |
1384 | if (loop != evapi.default_loop) |
1371 | ev_loop_destroy (loop); |
1385 | ev_loop_destroy (loop); |
1372 | |
1386 | |
1373 | void ev_loop_fork (struct ev_loop *loop) |
1387 | void ev_loop_fork (struct ev_loop *loop) |
… | |
… | |
1396 | |
1410 | |
1397 | unsigned int ev_depth (struct ev_loop *loop) |
1411 | unsigned int ev_depth (struct ev_loop *loop) |
1398 | ALIAS: |
1412 | ALIAS: |
1399 | loop_depth = 1 |
1413 | loop_depth = 1 |
1400 | |
1414 | |
1401 | void ev_run (struct ev_loop *loop, int flags = 0) |
1415 | int ev_run (struct ev_loop *loop, int flags = 0) |
1402 | ALIAS: |
1416 | ALIAS: |
1403 | loop = 1 |
1417 | loop = 1 |
1404 | |
1418 | |
1405 | void ev_break (struct ev_loop *loop, int how = 1) |
1419 | void ev_break (struct ev_loop *loop, int how = 1) |
1406 | ALIAS: |
1420 | ALIAS: |
… | |
… | |
1415 | #if 0 |
1429 | #if 0 |
1416 | |
1430 | |
1417 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
1431 | void ev_feed_signal_event (struct ev_loop *loop, SV *signal) |
1418 | CODE: |
1432 | CODE: |
1419 | { |
1433 | { |
1420 | Signal signum = s_signum (signal); |
1434 | Signal signum = s_signum (signal); |
1421 | CHECK_SIG (signal, signum); |
1435 | CHECK_SIG (signal, signum); |
1422 | |
1436 | |
1423 | ev_feed_signal_event (loop, signum); |
1437 | ev_feed_signal_event (loop, signum); |
1424 | } |
1438 | } |
1425 | |
1439 | |
… | |
… | |
1458 | periodic_ns = 1 |
1472 | periodic_ns = 1 |
1459 | INIT: |
1473 | INIT: |
1460 | CHECK_REPEAT (interval); |
1474 | CHECK_REPEAT (interval); |
1461 | CODE: |
1475 | CODE: |
1462 | { |
1476 | { |
1463 | ev_periodic *w; |
1477 | ev_periodic *w; |
1464 | w = e_new (sizeof (ev_periodic), cb, ST (0)); |
1478 | w = e_new (sizeof (ev_periodic), cb, ST (0)); |
1465 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
1479 | e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; |
1466 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
1480 | ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0); |
1467 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
1481 | RETVAL = e_bless ((ev_watcher *)w, stash_periodic); |
1468 | if (!ix) START (periodic, w); |
1482 | if (!ix) START (periodic, w); |
… | |
… | |
1473 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
1487 | ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) |
1474 | ALIAS: |
1488 | ALIAS: |
1475 | signal_ns = 1 |
1489 | signal_ns = 1 |
1476 | CODE: |
1490 | CODE: |
1477 | { |
1491 | { |
1478 | Signal signum = s_signum (signal); |
1492 | Signal signum = s_signum (signal); |
1479 | CHECK_SIG (signal, signum); |
1493 | CHECK_SIG (signal, signum); |
1480 | |
1494 | |
1481 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
1495 | RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); |
1482 | ev_signal_set (RETVAL, signum); |
1496 | ev_signal_set (RETVAL, signum); |
1483 | if (!ix) START_SIGNAL (RETVAL); |
1497 | if (!ix) START_SIGNAL (RETVAL); |
… | |
… | |
1523 | ev_fork_set (RETVAL); |
1537 | ev_fork_set (RETVAL); |
1524 | if (!ix) START (fork, RETVAL); |
1538 | if (!ix) START (fork, RETVAL); |
1525 | OUTPUT: |
1539 | OUTPUT: |
1526 | RETVAL |
1540 | RETVAL |
1527 | |
1541 | |
|
|
1542 | #if CLEANUP_ENABLED |
|
|
1543 | |
1528 | ev_cleanup *cleanup (struct ev_loop *loop, SV *cb) |
1544 | ev_cleanup *cleanup (struct ev_loop *loop, SV *cb) |
1529 | ALIAS: |
1545 | ALIAS: |
1530 | cleanup_ns = 1 |
1546 | cleanup_ns = 1 |
1531 | CODE: |
1547 | CODE: |
1532 | RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0)); |
1548 | RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0)); |
|
|
1549 | SvREFCNT_dec (RETVAL->loop); /* must not keep loop object alive */ |
1533 | ev_cleanup_set (RETVAL); |
1550 | ev_cleanup_set (RETVAL); |
1534 | if (!ix) START (cleanup, RETVAL); |
1551 | if (!ix) START (cleanup, RETVAL); |
1535 | OUTPUT: |
1552 | OUTPUT: |
1536 | RETVAL |
1553 | RETVAL |
|
|
1554 | |
|
|
1555 | #endif |
1537 | |
1556 | |
1538 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
1557 | ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) |
1539 | ALIAS: |
1558 | ALIAS: |
1540 | child_ns = 1 |
1559 | child_ns = 1 |
1541 | CODE: |
1560 | CODE: |