ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV.xs
(Generate patch)

Comparing EV/EV.xs (file contents):
Revision 1.132 by root, Sun Jul 19 21:59:55 2009 UTC vs.
Revision 1.141 by root, Thu Jul 8 00:45:03 2010 UTC

13sv_fileno (SV *fh) 13sv_fileno (SV *fh)
14{ 14{
15 return s_fileno (fh, 0); 15 return s_fileno (fh, 0);
16} 16}
17 17
18#define EV_STANDALONE 1
18#define EV_PROTOTYPES 1 19#define EV_PROTOTYPES 1
19#define EV_USE_NANOSLEEP EV_USE_MONOTONIC 20#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
20#define EV_H <ev.h> 21#define EV_H <ev.h>
22#define EV_CONFIG_H error
21#include "EV/EVAPI.h" 23#include "EV/EVAPI.h"
22 24
23#define EV_SELECT_IS_WINSOCKET 0 25#define EV_SELECT_IS_WINSOCKET 0
24#ifdef _WIN32 26#ifdef _WIN32
25# define EV_SELECT_USE_FD_SET 0 27# define EV_SELECT_USE_FD_SET 0
27# define fd_mask Perl_fd_mask 29# define fd_mask Perl_fd_mask
28#endif 30#endif
29/* due to bugs in OS X we have to use libev/ explicitly here */ 31/* due to bugs in OS X we have to use libev/ explicitly here */
30#include "libev/ev.c" 32#include "libev/ev.c"
31 33
32#ifndef _WIN32 34#if !defined(_WIN32) && !defined(_MINIX)
33# include <pthread.h> 35# include <pthread.h>
34#endif 36#endif
35 37
36#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) 38#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop))
39#define e_flags(w) ((ev_watcher *)(w))->e_flags
40#define e_self(w) ((ev_watcher *)(w))->self
41#define e_fh(w) ((ev_watcher *)(w))->fh
42#define e_data(w) ((ev_watcher *)(w))->data
37 43
38#define WFLAG_KEEPALIVE 1 44#define WFLAG_KEEPALIVE 1
39#define WFLAG_UNREFED 2 /* has been unref'ed */ 45#define WFLAG_UNREFED 2 /* has been unref'ed */
40 46
41#define UNREF(w) \ 47#define UNREF(w) \
42 if (!((w)->e_flags & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \ 48 if (!(e_flags (w) & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \
43 && ev_is_active (w)) \ 49 && ev_is_active (w)) \
44 { \ 50 { \
45 ev_unref (e_loop (w)); \ 51 ev_unref (e_loop (w)); \
46 (w)->e_flags |= WFLAG_UNREFED; \ 52 e_flags (w) |= WFLAG_UNREFED; \
47 } 53 }
48 54
49#define REF(w) \ 55#define REF(w) \
50 if ((w)->e_flags & WFLAG_UNREFED) \ 56 if (e_flags (w) & WFLAG_UNREFED) \
51 { \ 57 { \
52 (w)->e_flags &= ~WFLAG_UNREFED; \ 58 e_flags (w) &= ~WFLAG_UNREFED; \
53 ev_ref (e_loop (w)); \ 59 ev_ref (e_loop (w)); \
54 } 60 }
55 61
56#define START(type,w) \ 62#define START(type,w) \
57 do { \ 63 do { \
121///////////////////////////////////////////////////////////////////////////// 127/////////////////////////////////////////////////////////////////////////////
122// Event 128// Event
123 129
124static void e_cb (EV_P_ ev_watcher *w, int revents); 130static void e_cb (EV_P_ ev_watcher *w, int revents);
125 131
126static void * 132void *
127e_new (int size, SV *cb_sv, SV *loop) 133e_new (int size, SV *cb_sv, SV *loop)
128{ 134{
129 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0; 135 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0;
130 ev_watcher *w; 136 ev_watcher *w;
131 SV *self = NEWSV (0, size); 137 SV *self = NEWSV (0, size);
193 sv_self = sv_self_cache; sv_self_cache = 0; 199 sv_self = sv_self_cache; sv_self_cache = 0;
194 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); 200 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self));
195 } 201 }
196 else 202 else
197 { 203 {
198 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ 204 sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */
199 SvREADONLY_on (sv_self); 205 SvREADONLY_on (sv_self);
200 } 206 }
201 207
202 if (expect_true (sv_events_cache)) 208 if (expect_true (sv_events_cache))
203 { 209 {
294 ENTER; 300 ENTER;
295 SAVETMPS; 301 SAVETMPS;
296 302
297 PUSHMARK (SP); 303 PUSHMARK (SP);
298 EXTEND (SP, 2); 304 EXTEND (SP, 2);
299 PUSHs (newRV_inc (w->self)); /* w->self MUST be blessed by now */ 305 PUSHs (newRV_inc (e_self (w))); /* e_self (w) MUST be blessed by now */
300 PUSHs (newSVnv (now)); 306 PUSHs (newSVnv (now));
301 307
302 PUTBACK; 308 PUTBACK;
303 count = call_sv (w->fh, G_SCALAR | G_EVAL); 309 count = call_sv (w->fh, G_SCALAR | G_EVAL);
304 SPAGAIN; 310 SPAGAIN;
358 const_iv (EV_, UNDEF) 364 const_iv (EV_, UNDEF)
359 const_iv (EV_, NONE) 365 const_iv (EV_, NONE)
360 const_iv (EV_, READ) 366 const_iv (EV_, READ)
361 const_iv (EV_, WRITE) 367 const_iv (EV_, WRITE)
362 const_iv (EV_, IO) 368 const_iv (EV_, IO)
363 const_iv (EV_, TIMEOUT) 369 const_iv (EV_, TIMEOUT) /* deprecated */
364 const_iv (EV_, TIMER) 370 const_iv (EV_, TIMER)
365 const_iv (EV_, PERIODIC) 371 const_iv (EV_, PERIODIC)
366 const_iv (EV_, SIGNAL) 372 const_iv (EV_, SIGNAL)
367 const_iv (EV_, CHILD) 373 const_iv (EV_, CHILD)
368 const_iv (EV_, STAT) 374 const_iv (EV_, STAT)
386 const_iv (EV, BACKEND_POLL) 392 const_iv (EV, BACKEND_POLL)
387 const_iv (EV, BACKEND_EPOLL) 393 const_iv (EV, BACKEND_EPOLL)
388 const_iv (EV, BACKEND_KQUEUE) 394 const_iv (EV, BACKEND_KQUEUE)
389 const_iv (EV, BACKEND_DEVPOLL) 395 const_iv (EV, BACKEND_DEVPOLL)
390 const_iv (EV, BACKEND_PORT) 396 const_iv (EV, BACKEND_PORT)
397 const_iv (EV, BACKEND_ALL)
391 const_iv (EV, FLAG_AUTO) 398 const_iv (EV, FLAG_AUTO)
399 const_iv (EV, FLAG_FORKCHECK)
400 const_iv (EV, FLAG_SIGNALFD)
392 const_iv (EV, FLAG_NOENV) 401 const_iv (EV, FLAG_NOENV)
402 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
393 const_iv (EV, FLAG_FORKCHECK) 403 const_iv (EV, FLAG_NOINOTIFY)
394 404
395 const_iv (EV_, VERSION_MAJOR) 405 const_iv (EV_, VERSION_MAJOR)
396 const_iv (EV_, VERSION_MINOR) 406 const_iv (EV_, VERSION_MINOR)
397 }; 407 };
398 408
429 evapi.time_ = ev_time; 439 evapi.time_ = ev_time;
430 evapi.sleep_ = ev_sleep; 440 evapi.sleep_ = ev_sleep;
431 evapi.loop_new = ev_loop_new; 441 evapi.loop_new = ev_loop_new;
432 evapi.loop_destroy = ev_loop_destroy; 442 evapi.loop_destroy = ev_loop_destroy;
433 evapi.loop_fork = ev_loop_fork; 443 evapi.loop_fork = ev_loop_fork;
434 evapi.loop_count = ev_loop_count; 444 evapi.iteration = ev_iteration;
435 evapi.loop_depth = ev_loop_depth; 445 evapi.depth = ev_depth;
436 evapi.set_userdata = ev_set_userdata; 446 evapi.set_userdata = ev_set_userdata;
437 evapi.userdata = ev_userdata; 447 evapi.userdata = ev_userdata;
438 evapi.now = ev_now; 448 evapi.now = ev_now;
439 evapi.now_update = ev_now_update; 449 evapi.now_update = ev_now_update;
440 evapi.suspend = ev_suspend; 450 evapi.suspend = ev_suspend;
441 evapi.resume = ev_resume; 451 evapi.resume = ev_resume;
442 evapi.backend = ev_backend; 452 evapi.backend = ev_backend;
443 evapi.unloop = ev_unloop; 453 evapi.unloop = ev_unloop;
444 evapi.invoke_pending = ev_invoke_pending; 454 evapi.invoke_pending = ev_invoke_pending;
445 evapi.pending_count = ev_pending_count; 455 evapi.pending_count = ev_pending_count;
456 evapi.verify = ev_verify;
446 evapi.set_loop_release_cb = ev_set_loop_release_cb; 457 evapi.set_loop_release_cb = ev_set_loop_release_cb;
447 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; 458 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb;
448 evapi.ref = ev_ref; 459 evapi.ref = ev_ref;
449 evapi.unref = ev_unref; 460 evapi.unref = ev_unref;
450 evapi.loop = ev_loop; 461 evapi.loop = ev_loop;
463 evapi.idle_stop = ev_idle_stop; 474 evapi.idle_stop = ev_idle_stop;
464 evapi.prepare_start = ev_prepare_start; 475 evapi.prepare_start = ev_prepare_start;
465 evapi.prepare_stop = ev_prepare_stop; 476 evapi.prepare_stop = ev_prepare_stop;
466 evapi.check_start = ev_check_start; 477 evapi.check_start = ev_check_start;
467 evapi.check_stop = ev_check_stop; 478 evapi.check_stop = ev_check_stop;
479#if EV_CHILD_ENABLE
468 evapi.child_start = ev_child_start; 480 evapi.child_start = ev_child_start;
469 evapi.child_stop = ev_child_stop; 481 evapi.child_stop = ev_child_stop;
482#endif
470 evapi.stat_start = ev_stat_start; 483 evapi.stat_start = ev_stat_start;
471 evapi.stat_stop = ev_stat_stop; 484 evapi.stat_stop = ev_stat_stop;
472 evapi.stat_stat = ev_stat_stat; 485 evapi.stat_stat = ev_stat_stat;
473 evapi.embed_start = ev_embed_start; 486 evapi.embed_start = ev_embed_start;
474 evapi.embed_stop = ev_embed_stop; 487 evapi.embed_stop = ev_embed_stop;
482 evapi.invoke = ev_invoke; 495 evapi.invoke = ev_invoke;
483 496
484 sv_setiv (sv, (IV)&evapi); 497 sv_setiv (sv, (IV)&evapi);
485 SvREADONLY_on (sv); 498 SvREADONLY_on (sv);
486 } 499 }
487#ifndef _WIN32 500#if !defined(_WIN32) && !defined(_MINIX)
488 pthread_atfork (0, 0, ev_default_fork); 501 pthread_atfork (0, 0, ev_default_fork);
489#endif 502#endif
490} 503}
491 504
492SV *ev_default_loop (unsigned int flags = 0) 505SV *ev_default_loop (unsigned int flags = 0)
536 C_ARGS: evapi.default_loop 549 C_ARGS: evapi.default_loop
537 550
538unsigned int ev_backend () 551unsigned int ev_backend ()
539 C_ARGS: evapi.default_loop 552 C_ARGS: evapi.default_loop
540 553
541void ev_loop_verify () 554void ev_verify ()
542 C_ARGS: evapi.default_loop 555 C_ARGS: evapi.default_loop
543 556
544unsigned int ev_loop_count () 557unsigned int ev_iteration ()
545 C_ARGS: evapi.default_loop 558 C_ARGS: evapi.default_loop
546 559
547unsigned int ev_loop_depth () 560unsigned int ev_depth ()
548 C_ARGS: evapi.default_loop 561 C_ARGS: evapi.default_loop
549 562
550void ev_set_io_collect_interval (NV interval) 563void ev_set_io_collect_interval (NV interval)
551 C_ARGS: evapi.default_loop, interval 564 C_ARGS: evapi.default_loop, interval
552 565
578 C_ARGS: evapi.default_loop 591 C_ARGS: evapi.default_loop
579 592
580ev_io *io (SV *fh, int events, SV *cb) 593ev_io *io (SV *fh, int events, SV *cb)
581 ALIAS: 594 ALIAS:
582 io_ns = 1 595 io_ns = 1
596 _ae_io = 2
583 CODE: 597 CODE:
584{ 598{
585 int fd = s_fileno (fh, events & EV_WRITE); 599 int fd = s_fileno (fh, events & EV_WRITE);
586 CHECK_FD (fh, fd); 600 CHECK_FD (fh, fd);
587 601
602 if (ix == 2)
603 {
604 ix = 0;
605 events = events ? EV_WRITE : EV_READ;
606 }
607
588 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); 608 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv);
589 RETVAL->fh = newSVsv (fh); 609 e_fh (RETVAL) = newSVsv (fh);
590 ev_io_set (RETVAL, fd, events); 610 ev_io_set (RETVAL, fd, events);
591 if (!ix) START (io, RETVAL); 611 if (!ix) START (io, RETVAL);
592} 612}
593 OUTPUT: 613 OUTPUT:
594 RETVAL 614 RETVAL
612 CHECK_REPEAT (interval); 632 CHECK_REPEAT (interval);
613 CODE: 633 CODE:
614{ 634{
615 ev_periodic *w; 635 ev_periodic *w;
616 w = e_new (sizeof (ev_periodic), cb, default_loop_sv); 636 w = e_new (sizeof (ev_periodic), cb, default_loop_sv);
617 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 637 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
618 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 638 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
619 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 639 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
620 if (!ix) START (periodic, w); 640 if (!ix) START (periodic, w);
621} 641}
622 OUTPUT: 642 OUTPUT:
623 RETVAL 643 RETVAL
675 ev_fork_set (RETVAL); 695 ev_fork_set (RETVAL);
676 if (!ix) START (fork, RETVAL); 696 if (!ix) START (fork, RETVAL);
677 OUTPUT: 697 OUTPUT:
678 RETVAL 698 RETVAL
679 699
700
680ev_child *child (int pid, int trace, SV *cb) 701ev_child *child (int pid, int trace, SV *cb)
681 ALIAS: 702 ALIAS:
682 child_ns = 1 703 child_ns = 1
683 CODE: 704 CODE:
705#if EV_CHILD_ENABLE
684 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); 706 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv);
685 ev_child_set (RETVAL, pid, trace); 707 ev_child_set (RETVAL, pid, trace);
686 if (!ix) START (child, RETVAL); 708 if (!ix) START (child, RETVAL);
709#else
710 croak ("EV::child watchers not supported on this platform");
711#endif
687 OUTPUT: 712 OUTPUT:
688 RETVAL 713 RETVAL
714
689 715
690ev_stat *stat (SV *path, NV interval, SV *cb) 716ev_stat *stat (SV *path, NV interval, SV *cb)
691 ALIAS: 717 ALIAS:
692 stat_ns = 1 718 stat_ns = 1
693 CODE: 719 CODE:
694 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv); 720 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv);
695 RETVAL->fh = newSVsv (path); 721 e_fh (RETVAL) = newSVsv (path);
696 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 722 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
697 if (!ix) START (stat, RETVAL); 723 if (!ix) START (stat, RETVAL);
698 OUTPUT: 724 OUTPUT:
699 RETVAL 725 RETVAL
700 726
701ev_embed *embed (struct ev_loop *loop, SV *cb = 0) 727ev_embed *embed (struct ev_loop *loop, SV *cb = 0)
705{ 731{
706 if (!(ev_backend (loop) & ev_embeddable_backends ())) 732 if (!(ev_backend (loop) & ev_embeddable_backends ()))
707 croak ("passed loop is not embeddable via EV::embed,"); 733 croak ("passed loop is not embeddable via EV::embed,");
708 734
709 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv); 735 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv);
710 RETVAL->fh = newSVsv (ST (0)); 736 e_fh (RETVAL) = newSVsv (ST (0));
711 ev_embed_set (RETVAL, loop); 737 ev_embed_set (RETVAL, loop);
712 if (!ix) START (embed, RETVAL); 738 if (!ix) START (embed, RETVAL);
713} 739}
714 OUTPUT: 740 OUTPUT:
715 RETVAL 741 RETVAL
853 CODE: 879 CODE:
854{ 880{
855 int fd = s_fileno (fh, events & EV_WRITE); 881 int fd = s_fileno (fh, events & EV_WRITE);
856 CHECK_FD (fh, fd); 882 CHECK_FD (fh, fd);
857 883
858 sv_setsv (w->fh, fh); 884 sv_setsv (e_fh (w), fh);
859 RESET (io, w, (w, fd, events)); 885 RESET (io, w, (w, fd, events));
860} 886}
861 887
862SV *fh (ev_io *w, SV *new_fh = 0) 888SV *fh (ev_io *w, SV *new_fh = 0)
863 CODE: 889 CODE:
865 if (items > 1) 891 if (items > 1)
866 { 892 {
867 int fd = s_fileno (new_fh, w->events & EV_WRITE); 893 int fd = s_fileno (new_fh, w->events & EV_WRITE);
868 CHECK_FD (new_fh, fd); 894 CHECK_FD (new_fh, fd);
869 895
870 RETVAL = w->fh; 896 RETVAL = e_fh (w);
871 w->fh = newSVsv (new_fh); 897 e_fh (w) = newSVsv (new_fh);
872 898
873 RESET (io, w, (w, fd, w->events)); 899 RESET (io, w, (w, fd, w->events));
874 } 900 }
875 else 901 else
876 RETVAL = newSVsv (w->fh); 902 RETVAL = newSVsv (e_fh (w));
877} 903}
878 OUTPUT: 904 OUTPUT:
879 RETVAL 905 RETVAL
880 906
881int events (ev_io *w, int new_events = EV_UNDEF) 907int events (ev_io *w, int new_events = EV_UNDEF)
987void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) 1013void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef)
988 INIT: 1014 INIT:
989 CHECK_REPEAT (interval); 1015 CHECK_REPEAT (interval);
990 CODE: 1016 CODE:
991{ 1017{
992 SvREFCNT_dec (w->fh); 1018 SvREFCNT_dec (e_fh (w));
993 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1019 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
994 1020
995 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 1021 RESET (periodic, w, (w, at, interval, e_fh (w) ? e_periodic_cb : 0));
996} 1022}
997 1023
998NV at (ev_periodic *w) 1024NV at (ev_periodic *w)
999 CODE: 1025 CODE:
1000 RETVAL = ev_periodic_at (w); 1026 RETVAL = ev_periodic_at (w);
1060 CODE: 1086 CODE:
1061 STOP (fork, w); 1087 STOP (fork, w);
1062 e_destroy (w); 1088 e_destroy (w);
1063 1089
1064MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 1090MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
1091
1092#if EV_CHILD_ENABLE
1065 1093
1066void ev_child_start (ev_child *w) 1094void ev_child_start (ev_child *w)
1067 CODE: 1095 CODE:
1068 START (child, w); 1096 START (child, w);
1069 1097
1089 : ix == 1 ? w->rpid 1117 : ix == 1 ? w->rpid
1090 : w->rstatus; 1118 : w->rstatus;
1091 OUTPUT: 1119 OUTPUT:
1092 RETVAL 1120 RETVAL
1093 1121
1122#endif
1123
1094MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ 1124MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_
1095 1125
1096void ev_stat_start (ev_stat *w) 1126void ev_stat_start (ev_stat *w)
1097 CODE: 1127 CODE:
1098 START (stat, w); 1128 START (stat, w);
1107 e_destroy (w); 1137 e_destroy (w);
1108 1138
1109void set (ev_stat *w, SV *path, NV interval) 1139void set (ev_stat *w, SV *path, NV interval)
1110 CODE: 1140 CODE:
1111{ 1141{
1112 sv_setsv (w->fh, path); 1142 sv_setsv (e_fh (w), path);
1113 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), interval)); 1143 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1114} 1144}
1115 1145
1116SV *path (ev_stat *w, SV *new_path = 0) 1146SV *path (ev_stat *w, SV *new_path = 0)
1117 CODE: 1147 CODE:
1118{ 1148{
1119 RETVAL = SvREFCNT_inc (w->fh); 1149 RETVAL = SvREFCNT_inc (e_fh (w));
1120 1150
1121 if (items > 1) 1151 if (items > 1)
1122 { 1152 {
1123 SvREFCNT_dec (w->fh); 1153 SvREFCNT_dec (e_fh (w));
1124 w->fh = newSVsv (new_path); 1154 e_fh (w) = newSVsv (new_path);
1125 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), w->interval)); 1155 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1126 } 1156 }
1127} 1157}
1128 OUTPUT: 1158 OUTPUT:
1129 RETVAL 1159 RETVAL
1130 1160
1132 CODE: 1162 CODE:
1133{ 1163{
1134 RETVAL = w->interval; 1164 RETVAL = w->interval;
1135 1165
1136 if (items > 1) 1166 if (items > 1)
1137 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), new_interval)); 1167 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval));
1138} 1168}
1139 OUTPUT: 1169 OUTPUT:
1140 RETVAL 1170 RETVAL
1141 1171
1142void prev (ev_stat *w) 1172void prev (ev_stat *w)
1201 e_destroy (w); 1231 e_destroy (w);
1202 1232
1203void set (ev_embed *w, struct ev_loop *loop) 1233void set (ev_embed *w, struct ev_loop *loop)
1204 CODE: 1234 CODE:
1205{ 1235{
1206 sv_setsv (w->fh, ST (1)); 1236 sv_setsv (e_fh (w), ST (1));
1207 RESET (embed, w, (w, loop)); 1237 RESET (embed, w, (w, loop));
1208} 1238}
1209 1239
1210SV *other (ev_embed *w) 1240SV *other (ev_embed *w)
1211 CODE: 1241 CODE:
1212 RETVAL = newSVsv (w->fh); 1242 RETVAL = newSVsv (e_fh (w));
1213 OUTPUT: 1243 OUTPUT:
1214 RETVAL 1244 RETVAL
1215 1245
1216void ev_embed_sweep (ev_embed *w) 1246void ev_embed_sweep (ev_embed *w)
1217 C_ARGS: e_loop (w), w 1247 C_ARGS: e_loop (w), w
1260 if (loop != evapi.default_loop) /* global destruction sucks */ 1290 if (loop != evapi.default_loop) /* global destruction sucks */
1261 ev_loop_destroy (loop); 1291 ev_loop_destroy (loop);
1262 1292
1263void ev_loop_fork (struct ev_loop *loop) 1293void ev_loop_fork (struct ev_loop *loop)
1264 1294
1265void ev_loop_verify (struct ev_loop *loop) 1295void ev_verify (struct ev_loop *loop)
1266 1296
1267NV ev_now (struct ev_loop *loop) 1297NV ev_now (struct ev_loop *loop)
1268 1298
1269void ev_now_update (struct ev_loop *loop) 1299void ev_now_update (struct ev_loop *loop)
1270 1300
1276 1306
1277void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) 1307void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1278 1308
1279unsigned int ev_backend (struct ev_loop *loop) 1309unsigned int ev_backend (struct ev_loop *loop)
1280 1310
1281unsigned int ev_loop_count (struct ev_loop *loop) 1311unsigned int ev_iteration (struct ev_loop *loop)
1282 1312
1283unsigned int ev_loop_depth (struct ev_loop *loop) 1313unsigned int ev_depth (struct ev_loop *loop)
1284 1314
1285void ev_loop (struct ev_loop *loop, int flags = 0) 1315void ev_loop (struct ev_loop *loop, int flags = 0)
1286 1316
1287void ev_unloop (struct ev_loop *loop, int how = 1) 1317void ev_unloop (struct ev_loop *loop, int how = 1)
1288 1318
1312{ 1342{
1313 int fd = s_fileno (fh, events & EV_WRITE); 1343 int fd = s_fileno (fh, events & EV_WRITE);
1314 CHECK_FD (fh, fd); 1344 CHECK_FD (fh, fd);
1315 1345
1316 RETVAL = e_new (sizeof (ev_io), cb, ST (0)); 1346 RETVAL = e_new (sizeof (ev_io), cb, ST (0));
1317 RETVAL->fh = newSVsv (fh); 1347 e_fh (RETVAL) = newSVsv (fh);
1318 ev_io_set (RETVAL, fd, events); 1348 ev_io_set (RETVAL, fd, events);
1319 if (!ix) START (io, RETVAL); 1349 if (!ix) START (io, RETVAL);
1320} 1350}
1321 OUTPUT: 1351 OUTPUT:
1322 RETVAL 1352 RETVAL
1340 CHECK_REPEAT (interval); 1370 CHECK_REPEAT (interval);
1341 CODE: 1371 CODE:
1342{ 1372{
1343 ev_periodic *w; 1373 ev_periodic *w;
1344 w = e_new (sizeof (ev_periodic), cb, ST (0)); 1374 w = e_new (sizeof (ev_periodic), cb, ST (0));
1345 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1375 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1346 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 1376 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
1347 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 1377 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1348 if (!ix) START (periodic, w); 1378 if (!ix) START (periodic, w);
1349} 1379}
1350 OUTPUT: 1380 OUTPUT:
1351 RETVAL 1381 RETVAL
1403 ev_fork_set (RETVAL); 1433 ev_fork_set (RETVAL);
1404 if (!ix) START (fork, RETVAL); 1434 if (!ix) START (fork, RETVAL);
1405 OUTPUT: 1435 OUTPUT:
1406 RETVAL 1436 RETVAL
1407 1437
1438
1408ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) 1439ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1409 ALIAS: 1440 ALIAS:
1410 child_ns = 1 1441 child_ns = 1
1411 CODE: 1442 CODE:
1443#if EV_CHILD_ENABLE
1412 RETVAL = e_new (sizeof (ev_child), cb, ST (0)); 1444 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1413 ev_child_set (RETVAL, pid, trace); 1445 ev_child_set (RETVAL, pid, trace);
1414 if (!ix) START (child, RETVAL); 1446 if (!ix) START (child, RETVAL);
1447#else
1448 croak ("EV::child watchers not supported on this platform");
1449#endif
1415 OUTPUT: 1450 OUTPUT:
1416 RETVAL 1451 RETVAL
1417 1452
1418ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) 1453ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1419 ALIAS: 1454 ALIAS:
1420 stat_ns = 1 1455 stat_ns = 1
1421 CODE: 1456 CODE:
1422 RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); 1457 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1423 RETVAL->fh = newSVsv (path); 1458 e_fh (RETVAL) = newSVsv (path);
1424 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 1459 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
1425 if (!ix) START (stat, RETVAL); 1460 if (!ix) START (stat, RETVAL);
1426 OUTPUT: 1461 OUTPUT:
1427 RETVAL 1462 RETVAL
1428 1463
1429ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0) 1464ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0)
1433{ 1468{
1434 if (!(ev_backend (other) & ev_embeddable_backends ())) 1469 if (!(ev_backend (other) & ev_embeddable_backends ()))
1435 croak ("passed loop is not embeddable via EV::embed,"); 1470 croak ("passed loop is not embeddable via EV::embed,");
1436 1471
1437 RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); 1472 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1438 RETVAL->fh = newSVsv (ST (1)); 1473 e_fh (RETVAL) = newSVsv (ST (1));
1439 ev_embed_set (RETVAL, other); 1474 ev_embed_set (RETVAL, other);
1440 if (!ix) START (embed, RETVAL); 1475 if (!ix) START (embed, RETVAL);
1441} 1476}
1442 OUTPUT: 1477 OUTPUT:
1443 RETVAL 1478 RETVAL

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines