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

Comparing EV/EV.xs (file contents):
Revision 1.136 by root, Tue Mar 16 17:11:48 2010 UTC vs.
Revision 1.143 by root, Sat Oct 23 22:25:44 2010 UTC

29# define fd_mask Perl_fd_mask 29# define fd_mask Perl_fd_mask
30#endif 30#endif
31/* 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 */
32#include "libev/ev.c" 32#include "libev/ev.c"
33 33
34#ifndef _WIN32 34#if !defined(_WIN32) && !defined(_MINIX)
35# include <pthread.h> 35# include <pthread.h>
36#endif 36#endif
37 37
38#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
39 43
40#define WFLAG_KEEPALIVE 1 44#define WFLAG_KEEPALIVE 1
41#define WFLAG_UNREFED 2 /* has been unref'ed */ 45#define WFLAG_UNREFED 2 /* has been unref'ed */
42 46
43#define UNREF(w) \ 47#define UNREF(w) \
44 if (!((w)->e_flags & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \ 48 if (!(e_flags (w) & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \
45 && ev_is_active (w)) \ 49 && ev_is_active (w)) \
46 { \ 50 { \
47 ev_unref (e_loop (w)); \ 51 ev_unref (e_loop (w)); \
48 (w)->e_flags |= WFLAG_UNREFED; \ 52 e_flags (w) |= WFLAG_UNREFED; \
49 } 53 }
50 54
51#define REF(w) \ 55#define REF(w) \
52 if ((w)->e_flags & WFLAG_UNREFED) \ 56 if (e_flags (w) & WFLAG_UNREFED) \
53 { \ 57 { \
54 (w)->e_flags &= ~WFLAG_UNREFED; \ 58 e_flags (w) &= ~WFLAG_UNREFED; \
55 ev_ref (e_loop (w)); \ 59 ev_ref (e_loop (w)); \
56 } 60 }
57 61
58#define START(type,w) \ 62#define START(type,w) \
59 do { \ 63 do { \
123///////////////////////////////////////////////////////////////////////////// 127/////////////////////////////////////////////////////////////////////////////
124// Event 128// Event
125 129
126static void e_cb (EV_P_ ev_watcher *w, int revents); 130static void e_cb (EV_P_ ev_watcher *w, int revents);
127 131
128static void * 132void *
129e_new (int size, SV *cb_sv, SV *loop) 133e_new (int size, SV *cb_sv, SV *loop)
130{ 134{
131 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0; 135 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0;
132 ev_watcher *w; 136 ev_watcher *w;
133 SV *self = NEWSV (0, size); 137 SV *self = NEWSV (0, size);
195 sv_self = sv_self_cache; sv_self_cache = 0; 199 sv_self = sv_self_cache; sv_self_cache = 0;
196 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self)); 200 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self));
197 } 201 }
198 else 202 else
199 { 203 {
200 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 */
201 SvREADONLY_on (sv_self); 205 SvREADONLY_on (sv_self);
202 } 206 }
203 207
204 if (expect_true (sv_events_cache)) 208 if (expect_true (sv_events_cache))
205 { 209 {
296 ENTER; 300 ENTER;
297 SAVETMPS; 301 SAVETMPS;
298 302
299 PUSHMARK (SP); 303 PUSHMARK (SP);
300 EXTEND (SP, 2); 304 EXTEND (SP, 2);
301 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 */
302 PUSHs (newSVnv (now)); 306 PUSHs (newSVnv (now));
303 307
304 PUTBACK; 308 PUTBACK;
305 count = call_sv (w->fh, G_SCALAR | G_EVAL); 309 count = call_sv (w->fh, G_SCALAR | G_EVAL);
306 SPAGAIN; 310 SPAGAIN;
360 const_iv (EV_, UNDEF) 364 const_iv (EV_, UNDEF)
361 const_iv (EV_, NONE) 365 const_iv (EV_, NONE)
362 const_iv (EV_, READ) 366 const_iv (EV_, READ)
363 const_iv (EV_, WRITE) 367 const_iv (EV_, WRITE)
364 const_iv (EV_, IO) 368 const_iv (EV_, IO)
365 const_iv (EV_, TIMEOUT) /* deprecated */
366 const_iv (EV_, TIMER) 369 const_iv (EV_, TIMEOUT)
367 const_iv (EV_, PERIODIC) 370 const_iv (EV_, PERIODIC)
368 const_iv (EV_, SIGNAL) 371 const_iv (EV_, SIGNAL)
369 const_iv (EV_, CHILD) 372 const_iv (EV_, CHILD)
370 const_iv (EV_, STAT) 373 const_iv (EV_, STAT)
371 const_iv (EV_, IDLE) 374 const_iv (EV_, IDLE)
375 const_iv (EV_, FORK) 378 const_iv (EV_, FORK)
376 const_iv (EV_, ASYNC) 379 const_iv (EV_, ASYNC)
377 const_iv (EV_, CUSTOM) 380 const_iv (EV_, CUSTOM)
378 const_iv (EV_, ERROR) 381 const_iv (EV_, ERROR)
379 382
380 const_iv (EV, LOOP_NONBLOCK)
381 const_iv (EV, LOOP_ONESHOT)
382
383 const_iv (EV, UNLOOP_CANCEL) 383 const_iv (EV, RUN_NOWAIT)
384 const_iv (EV, UNLOOP_ONE) 384 const_iv (EV, RUN_ONCE)
385
386 const_iv (EV, BREAK_CANCEL)
387 const_iv (EV, BREAK_ONE)
385 const_iv (EV, UNLOOP_ALL) 388 const_iv (EV, BREAK_ALL)
386
387 const_iv (EV, BACKEND_SELECT) 389 const_iv (EV, BACKEND_SELECT)
388 const_iv (EV, BACKEND_POLL) 390 const_iv (EV, BACKEND_POLL)
389 const_iv (EV, BACKEND_EPOLL) 391 const_iv (EV, BACKEND_EPOLL)
390 const_iv (EV, BACKEND_KQUEUE) 392 const_iv (EV, BACKEND_KQUEUE)
391 const_iv (EV, BACKEND_DEVPOLL) 393 const_iv (EV, BACKEND_DEVPOLL)
398 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ 400 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
399 const_iv (EV, FLAG_NOINOTIFY) 401 const_iv (EV, FLAG_NOINOTIFY)
400 402
401 const_iv (EV_, VERSION_MAJOR) 403 const_iv (EV_, VERSION_MAJOR)
402 const_iv (EV_, VERSION_MINOR) 404 const_iv (EV_, VERSION_MINOR)
405#if EV_COMPAT3
406 const_iv (EV_, TIMER)
407
408 const_iv (EV, LOOP_NONBLOCK)
409 const_iv (EV, LOOP_ONESHOT)
410
411 const_iv (EV, UNLOOP_CANCEL)
412 const_iv (EV, UNLOOP_ONE)
413 const_iv (EV, UNLOOP_ALL)
414#endif
403 }; 415 };
404 416
405 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 417 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
406 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 418 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
407 419
435 evapi.time_ = ev_time; 447 evapi.time_ = ev_time;
436 evapi.sleep_ = ev_sleep; 448 evapi.sleep_ = ev_sleep;
437 evapi.loop_new = ev_loop_new; 449 evapi.loop_new = ev_loop_new;
438 evapi.loop_destroy = ev_loop_destroy; 450 evapi.loop_destroy = ev_loop_destroy;
439 evapi.loop_fork = ev_loop_fork; 451 evapi.loop_fork = ev_loop_fork;
440 evapi.loop_count = ev_loop_count; 452 evapi.iteration = ev_iteration;
441 evapi.loop_depth = ev_loop_depth; 453 evapi.depth = ev_depth;
442 evapi.set_userdata = ev_set_userdata; 454 evapi.set_userdata = ev_set_userdata;
443 evapi.userdata = ev_userdata; 455 evapi.userdata = ev_userdata;
444 evapi.now = ev_now; 456 evapi.now = ev_now;
445 evapi.now_update = ev_now_update; 457 evapi.now_update = ev_now_update;
446 evapi.suspend = ev_suspend; 458 evapi.suspend = ev_suspend;
447 evapi.resume = ev_resume; 459 evapi.resume = ev_resume;
448 evapi.backend = ev_backend; 460 evapi.backend = ev_backend;
449 evapi.unloop = ev_unloop; 461 evapi.break_ = ev_break;
450 evapi.invoke_pending = ev_invoke_pending; 462 evapi.invoke_pending = ev_invoke_pending;
451 evapi.pending_count = ev_pending_count; 463 evapi.pending_count = ev_pending_count;
464 evapi.verify = ev_verify;
452 evapi.set_loop_release_cb = ev_set_loop_release_cb; 465 evapi.set_loop_release_cb = ev_set_loop_release_cb;
453 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; 466 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb;
454 evapi.ref = ev_ref; 467 evapi.ref = ev_ref;
455 evapi.unref = ev_unref; 468 evapi.unref = ev_unref;
456 evapi.loop = ev_loop; 469 evapi.run = ev_run;
457 evapi.once = ev_once; 470 evapi.once = ev_once;
458 evapi.io_start = ev_io_start; 471 evapi.io_start = ev_io_start;
459 evapi.io_stop = ev_io_stop; 472 evapi.io_stop = ev_io_stop;
460 evapi.timer_start = ev_timer_start; 473 evapi.timer_start = ev_timer_start;
461 evapi.timer_stop = ev_timer_stop; 474 evapi.timer_stop = ev_timer_stop;
469 evapi.idle_stop = ev_idle_stop; 482 evapi.idle_stop = ev_idle_stop;
470 evapi.prepare_start = ev_prepare_start; 483 evapi.prepare_start = ev_prepare_start;
471 evapi.prepare_stop = ev_prepare_stop; 484 evapi.prepare_stop = ev_prepare_stop;
472 evapi.check_start = ev_check_start; 485 evapi.check_start = ev_check_start;
473 evapi.check_stop = ev_check_stop; 486 evapi.check_stop = ev_check_stop;
487#if EV_CHILD_ENABLE
474 evapi.child_start = ev_child_start; 488 evapi.child_start = ev_child_start;
475 evapi.child_stop = ev_child_stop; 489 evapi.child_stop = ev_child_stop;
490#endif
476 evapi.stat_start = ev_stat_start; 491 evapi.stat_start = ev_stat_start;
477 evapi.stat_stop = ev_stat_stop; 492 evapi.stat_stop = ev_stat_stop;
478 evapi.stat_stat = ev_stat_stat; 493 evapi.stat_stat = ev_stat_stat;
479 evapi.embed_start = ev_embed_start; 494 evapi.embed_start = ev_embed_start;
480 evapi.embed_stop = ev_embed_stop; 495 evapi.embed_stop = ev_embed_stop;
488 evapi.invoke = ev_invoke; 503 evapi.invoke = ev_invoke;
489 504
490 sv_setiv (sv, (IV)&evapi); 505 sv_setiv (sv, (IV)&evapi);
491 SvREADONLY_on (sv); 506 SvREADONLY_on (sv);
492 } 507 }
493#ifndef _WIN32 508#if !defined(_WIN32) && !defined(_MINIX)
494 pthread_atfork (0, 0, ev_default_fork); 509 pthread_atfork (0, 0, ev_default_fork);
495#endif 510#endif
496} 511}
497 512
498SV *ev_default_loop (unsigned int flags = 0) 513SV *ev_default_loop (unsigned int flags = 0)
542 C_ARGS: evapi.default_loop 557 C_ARGS: evapi.default_loop
543 558
544unsigned int ev_backend () 559unsigned int ev_backend ()
545 C_ARGS: evapi.default_loop 560 C_ARGS: evapi.default_loop
546 561
547void ev_loop_verify () 562void ev_verify ()
563 ALIAS:
564 loop_verify = 1
548 C_ARGS: evapi.default_loop 565 C_ARGS: evapi.default_loop
549 566
550unsigned int ev_loop_count () 567unsigned int ev_iteration ()
568 ALIAS:
569 loop_count = 1
551 C_ARGS: evapi.default_loop 570 C_ARGS: evapi.default_loop
552 571
553unsigned int ev_loop_depth () 572unsigned int ev_depth ()
573 ALIAS:
574 loop_depth = 1
554 C_ARGS: evapi.default_loop 575 C_ARGS: evapi.default_loop
555 576
556void ev_set_io_collect_interval (NV interval) 577void ev_set_io_collect_interval (NV interval)
557 C_ARGS: evapi.default_loop, interval 578 C_ARGS: evapi.default_loop, interval
558 579
559void ev_set_timeout_collect_interval (NV interval) 580void ev_set_timeout_collect_interval (NV interval)
560 C_ARGS: evapi.default_loop, interval 581 C_ARGS: evapi.default_loop, interval
561 582
562void ev_loop (int flags = 0) 583void ev_run (int flags = 0)
584 ALIAS:
585 loop = 1
563 C_ARGS: evapi.default_loop, flags 586 C_ARGS: evapi.default_loop, flags
564 587
565void ev_unloop (int how = EVUNLOOP_ONE) 588void ev_break (int how = EVBREAK_ONE)
589 ALIAS:
590 unloop = 1
566 C_ARGS: evapi.default_loop, how 591 C_ARGS: evapi.default_loop, how
567 592
568void ev_feed_fd_event (int fd, int revents = EV_NONE) 593void ev_feed_fd_event (int fd, int revents = EV_NONE)
569 C_ARGS: evapi.default_loop, fd, revents 594 C_ARGS: evapi.default_loop, fd, revents
570 595
597 ix = 0; 622 ix = 0;
598 events = events ? EV_WRITE : EV_READ; 623 events = events ? EV_WRITE : EV_READ;
599 } 624 }
600 625
601 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); 626 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv);
602 RETVAL->fh = newSVsv (fh); 627 e_fh (RETVAL) = newSVsv (fh);
603 ev_io_set (RETVAL, fd, events); 628 ev_io_set (RETVAL, fd, events);
604 if (!ix) START (io, RETVAL); 629 if (!ix) START (io, RETVAL);
605} 630}
606 OUTPUT: 631 OUTPUT:
607 RETVAL 632 RETVAL
625 CHECK_REPEAT (interval); 650 CHECK_REPEAT (interval);
626 CODE: 651 CODE:
627{ 652{
628 ev_periodic *w; 653 ev_periodic *w;
629 w = e_new (sizeof (ev_periodic), cb, default_loop_sv); 654 w = e_new (sizeof (ev_periodic), cb, default_loop_sv);
630 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 655 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
631 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 656 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
632 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 657 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
633 if (!ix) START (periodic, w); 658 if (!ix) START (periodic, w);
634} 659}
635 OUTPUT: 660 OUTPUT:
636 RETVAL 661 RETVAL
688 ev_fork_set (RETVAL); 713 ev_fork_set (RETVAL);
689 if (!ix) START (fork, RETVAL); 714 if (!ix) START (fork, RETVAL);
690 OUTPUT: 715 OUTPUT:
691 RETVAL 716 RETVAL
692 717
718
693ev_child *child (int pid, int trace, SV *cb) 719ev_child *child (int pid, int trace, SV *cb)
694 ALIAS: 720 ALIAS:
695 child_ns = 1 721 child_ns = 1
696 CODE: 722 CODE:
723#if EV_CHILD_ENABLE
697 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); 724 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv);
698 ev_child_set (RETVAL, pid, trace); 725 ev_child_set (RETVAL, pid, trace);
699 if (!ix) START (child, RETVAL); 726 if (!ix) START (child, RETVAL);
727#else
728 croak ("EV::child watchers not supported on this platform");
729#endif
700 OUTPUT: 730 OUTPUT:
701 RETVAL 731 RETVAL
732
702 733
703ev_stat *stat (SV *path, NV interval, SV *cb) 734ev_stat *stat (SV *path, NV interval, SV *cb)
704 ALIAS: 735 ALIAS:
705 stat_ns = 1 736 stat_ns = 1
706 CODE: 737 CODE:
707 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv); 738 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv);
708 RETVAL->fh = newSVsv (path); 739 e_fh (RETVAL) = newSVsv (path);
709 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 740 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
710 if (!ix) START (stat, RETVAL); 741 if (!ix) START (stat, RETVAL);
711 OUTPUT: 742 OUTPUT:
712 RETVAL 743 RETVAL
713 744
714ev_embed *embed (struct ev_loop *loop, SV *cb = 0) 745ev_embed *embed (struct ev_loop *loop, SV *cb = 0)
718{ 749{
719 if (!(ev_backend (loop) & ev_embeddable_backends ())) 750 if (!(ev_backend (loop) & ev_embeddable_backends ()))
720 croak ("passed loop is not embeddable via EV::embed,"); 751 croak ("passed loop is not embeddable via EV::embed,");
721 752
722 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv); 753 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv);
723 RETVAL->fh = newSVsv (ST (0)); 754 e_fh (RETVAL) = newSVsv (ST (0));
724 ev_embed_set (RETVAL, loop); 755 ev_embed_set (RETVAL, loop);
725 if (!ix) START (embed, RETVAL); 756 if (!ix) START (embed, RETVAL);
726} 757}
727 OUTPUT: 758 OUTPUT:
728 RETVAL 759 RETVAL
866 CODE: 897 CODE:
867{ 898{
868 int fd = s_fileno (fh, events & EV_WRITE); 899 int fd = s_fileno (fh, events & EV_WRITE);
869 CHECK_FD (fh, fd); 900 CHECK_FD (fh, fd);
870 901
871 sv_setsv (w->fh, fh); 902 sv_setsv (e_fh (w), fh);
872 RESET (io, w, (w, fd, events)); 903 RESET (io, w, (w, fd, events));
873} 904}
874 905
875SV *fh (ev_io *w, SV *new_fh = 0) 906SV *fh (ev_io *w, SV *new_fh = 0)
876 CODE: 907 CODE:
878 if (items > 1) 909 if (items > 1)
879 { 910 {
880 int fd = s_fileno (new_fh, w->events & EV_WRITE); 911 int fd = s_fileno (new_fh, w->events & EV_WRITE);
881 CHECK_FD (new_fh, fd); 912 CHECK_FD (new_fh, fd);
882 913
883 RETVAL = w->fh; 914 RETVAL = e_fh (w);
884 w->fh = newSVsv (new_fh); 915 e_fh (w) = newSVsv (new_fh);
885 916
886 RESET (io, w, (w, fd, w->events)); 917 RESET (io, w, (w, fd, w->events));
887 } 918 }
888 else 919 else
889 RETVAL = newSVsv (w->fh); 920 RETVAL = newSVsv (e_fh (w));
890} 921}
891 OUTPUT: 922 OUTPUT:
892 RETVAL 923 RETVAL
893 924
894int events (ev_io *w, int new_events = EV_UNDEF) 925int events (ev_io *w, int new_events = EV_UNDEF)
1000void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) 1031void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef)
1001 INIT: 1032 INIT:
1002 CHECK_REPEAT (interval); 1033 CHECK_REPEAT (interval);
1003 CODE: 1034 CODE:
1004{ 1035{
1005 SvREFCNT_dec (w->fh); 1036 SvREFCNT_dec (e_fh (w));
1006 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1037 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1007 1038
1008 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 1039 RESET (periodic, w, (w, at, interval, e_fh (w) ? e_periodic_cb : 0));
1009} 1040}
1010 1041
1011NV at (ev_periodic *w) 1042NV at (ev_periodic *w)
1012 CODE: 1043 CODE:
1013 RETVAL = ev_periodic_at (w); 1044 RETVAL = ev_periodic_at (w);
1073 CODE: 1104 CODE:
1074 STOP (fork, w); 1105 STOP (fork, w);
1075 e_destroy (w); 1106 e_destroy (w);
1076 1107
1077MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 1108MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
1109
1110#if EV_CHILD_ENABLE
1078 1111
1079void ev_child_start (ev_child *w) 1112void ev_child_start (ev_child *w)
1080 CODE: 1113 CODE:
1081 START (child, w); 1114 START (child, w);
1082 1115
1102 : ix == 1 ? w->rpid 1135 : ix == 1 ? w->rpid
1103 : w->rstatus; 1136 : w->rstatus;
1104 OUTPUT: 1137 OUTPUT:
1105 RETVAL 1138 RETVAL
1106 1139
1140#endif
1141
1107MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ 1142MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_
1108 1143
1109void ev_stat_start (ev_stat *w) 1144void ev_stat_start (ev_stat *w)
1110 CODE: 1145 CODE:
1111 START (stat, w); 1146 START (stat, w);
1120 e_destroy (w); 1155 e_destroy (w);
1121 1156
1122void set (ev_stat *w, SV *path, NV interval) 1157void set (ev_stat *w, SV *path, NV interval)
1123 CODE: 1158 CODE:
1124{ 1159{
1125 sv_setsv (w->fh, path); 1160 sv_setsv (e_fh (w), path);
1126 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), interval)); 1161 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1127} 1162}
1128 1163
1129SV *path (ev_stat *w, SV *new_path = 0) 1164SV *path (ev_stat *w, SV *new_path = 0)
1130 CODE: 1165 CODE:
1131{ 1166{
1132 RETVAL = SvREFCNT_inc (w->fh); 1167 RETVAL = SvREFCNT_inc (e_fh (w));
1133 1168
1134 if (items > 1) 1169 if (items > 1)
1135 { 1170 {
1136 SvREFCNT_dec (w->fh); 1171 SvREFCNT_dec (e_fh (w));
1137 w->fh = newSVsv (new_path); 1172 e_fh (w) = newSVsv (new_path);
1138 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), w->interval)); 1173 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1139 } 1174 }
1140} 1175}
1141 OUTPUT: 1176 OUTPUT:
1142 RETVAL 1177 RETVAL
1143 1178
1145 CODE: 1180 CODE:
1146{ 1181{
1147 RETVAL = w->interval; 1182 RETVAL = w->interval;
1148 1183
1149 if (items > 1) 1184 if (items > 1)
1150 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), new_interval)); 1185 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval));
1151} 1186}
1152 OUTPUT: 1187 OUTPUT:
1153 RETVAL 1188 RETVAL
1154 1189
1155void prev (ev_stat *w) 1190void prev (ev_stat *w)
1214 e_destroy (w); 1249 e_destroy (w);
1215 1250
1216void set (ev_embed *w, struct ev_loop *loop) 1251void set (ev_embed *w, struct ev_loop *loop)
1217 CODE: 1252 CODE:
1218{ 1253{
1219 sv_setsv (w->fh, ST (1)); 1254 sv_setsv (e_fh (w), ST (1));
1220 RESET (embed, w, (w, loop)); 1255 RESET (embed, w, (w, loop));
1221} 1256}
1222 1257
1223SV *other (ev_embed *w) 1258SV *other (ev_embed *w)
1224 CODE: 1259 CODE:
1225 RETVAL = newSVsv (w->fh); 1260 RETVAL = newSVsv (e_fh (w));
1226 OUTPUT: 1261 OUTPUT:
1227 RETVAL 1262 RETVAL
1228 1263
1229void ev_embed_sweep (ev_embed *w) 1264void ev_embed_sweep (ev_embed *w)
1230 C_ARGS: e_loop (w), w 1265 C_ARGS: e_loop (w), w
1268 OUTPUT: 1303 OUTPUT:
1269 RETVAL 1304 RETVAL
1270 1305
1271void DESTROY (struct ev_loop *loop) 1306void DESTROY (struct ev_loop *loop)
1272 CODE: 1307 CODE:
1273 if (loop != evapi.default_loop) /* global destruction sucks */ 1308 /* 1. the default loop shouldn't be freed by destroying it'S pelr loop object */
1309 /* 2. not doing so helps avoid many global destruction bugs in perl, too */
1310 if (loop != evapi.default_loop)
1274 ev_loop_destroy (loop); 1311 ev_loop_destroy (loop);
1275 1312
1276void ev_loop_fork (struct ev_loop *loop) 1313void ev_loop_fork (struct ev_loop *loop)
1277 1314
1278void ev_loop_verify (struct ev_loop *loop)
1279
1280NV ev_now (struct ev_loop *loop) 1315NV ev_now (struct ev_loop *loop)
1281 1316
1282void ev_now_update (struct ev_loop *loop) 1317void ev_now_update (struct ev_loop *loop)
1283 1318
1284void ev_suspend (struct ev_loop *loop) 1319void ev_suspend (struct ev_loop *loop)
1289 1324
1290void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) 1325void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1291 1326
1292unsigned int ev_backend (struct ev_loop *loop) 1327unsigned int ev_backend (struct ev_loop *loop)
1293 1328
1294unsigned int ev_loop_count (struct ev_loop *loop) 1329void ev_verify (struct ev_loop *loop)
1330 ALIAS:
1331 loop_verify = 1
1295 1332
1296unsigned int ev_loop_depth (struct ev_loop *loop) 1333unsigned int ev_iteration (struct ev_loop *loop)
1334 ALIAS:
1335 loop_count = 1
1297 1336
1298void ev_loop (struct ev_loop *loop, int flags = 0) 1337unsigned int ev_depth (struct ev_loop *loop)
1338 ALIAS:
1339 loop_depth = 1
1299 1340
1341void ev_run (struct ev_loop *loop, int flags = 0)
1342 ALIAS:
1343 loop = 1
1344
1300void ev_unloop (struct ev_loop *loop, int how = 1) 1345void ev_break (struct ev_loop *loop, int how = 1)
1346 ALIAS:
1347 unloop = 1
1301 1348
1302void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) 1349void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1303 1350
1304unsigned int ev_pending_count (struct ev_loop *loop) 1351unsigned int ev_pending_count (struct ev_loop *loop)
1305 1352
1325{ 1372{
1326 int fd = s_fileno (fh, events & EV_WRITE); 1373 int fd = s_fileno (fh, events & EV_WRITE);
1327 CHECK_FD (fh, fd); 1374 CHECK_FD (fh, fd);
1328 1375
1329 RETVAL = e_new (sizeof (ev_io), cb, ST (0)); 1376 RETVAL = e_new (sizeof (ev_io), cb, ST (0));
1330 RETVAL->fh = newSVsv (fh); 1377 e_fh (RETVAL) = newSVsv (fh);
1331 ev_io_set (RETVAL, fd, events); 1378 ev_io_set (RETVAL, fd, events);
1332 if (!ix) START (io, RETVAL); 1379 if (!ix) START (io, RETVAL);
1333} 1380}
1334 OUTPUT: 1381 OUTPUT:
1335 RETVAL 1382 RETVAL
1353 CHECK_REPEAT (interval); 1400 CHECK_REPEAT (interval);
1354 CODE: 1401 CODE:
1355{ 1402{
1356 ev_periodic *w; 1403 ev_periodic *w;
1357 w = e_new (sizeof (ev_periodic), cb, ST (0)); 1404 w = e_new (sizeof (ev_periodic), cb, ST (0));
1358 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1405 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1359 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 1406 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
1360 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 1407 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1361 if (!ix) START (periodic, w); 1408 if (!ix) START (periodic, w);
1362} 1409}
1363 OUTPUT: 1410 OUTPUT:
1364 RETVAL 1411 RETVAL
1416 ev_fork_set (RETVAL); 1463 ev_fork_set (RETVAL);
1417 if (!ix) START (fork, RETVAL); 1464 if (!ix) START (fork, RETVAL);
1418 OUTPUT: 1465 OUTPUT:
1419 RETVAL 1466 RETVAL
1420 1467
1468
1421ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) 1469ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1422 ALIAS: 1470 ALIAS:
1423 child_ns = 1 1471 child_ns = 1
1424 CODE: 1472 CODE:
1473#if EV_CHILD_ENABLE
1425 RETVAL = e_new (sizeof (ev_child), cb, ST (0)); 1474 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1426 ev_child_set (RETVAL, pid, trace); 1475 ev_child_set (RETVAL, pid, trace);
1427 if (!ix) START (child, RETVAL); 1476 if (!ix) START (child, RETVAL);
1477#else
1478 croak ("EV::child watchers not supported on this platform");
1479#endif
1428 OUTPUT: 1480 OUTPUT:
1429 RETVAL 1481 RETVAL
1430 1482
1431ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) 1483ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1432 ALIAS: 1484 ALIAS:
1433 stat_ns = 1 1485 stat_ns = 1
1434 CODE: 1486 CODE:
1435 RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); 1487 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1436 RETVAL->fh = newSVsv (path); 1488 e_fh (RETVAL) = newSVsv (path);
1437 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 1489 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
1438 if (!ix) START (stat, RETVAL); 1490 if (!ix) START (stat, RETVAL);
1439 OUTPUT: 1491 OUTPUT:
1440 RETVAL 1492 RETVAL
1441 1493
1442ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0) 1494ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0)
1446{ 1498{
1447 if (!(ev_backend (other) & ev_embeddable_backends ())) 1499 if (!(ev_backend (other) & ev_embeddable_backends ()))
1448 croak ("passed loop is not embeddable via EV::embed,"); 1500 croak ("passed loop is not embeddable via EV::embed,");
1449 1501
1450 RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); 1502 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1451 RETVAL->fh = newSVsv (ST (1)); 1503 e_fh (RETVAL) = newSVsv (ST (1));
1452 ev_embed_set (RETVAL, other); 1504 ev_embed_set (RETVAL, other);
1453 if (!ix) START (embed, RETVAL); 1505 if (!ix) START (embed, RETVAL);
1454} 1506}
1455 OUTPUT: 1507 OUTPUT:
1456 RETVAL 1508 RETVAL

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines