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

Comparing EV/EV.xs (file contents):
Revision 1.90 by root, Mon Dec 17 07:24:12 2007 UTC vs.
Revision 1.117 by root, Wed Oct 29 14:12:34 2008 UTC

2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5/*#include <netinet/in.h>*/ 5/*#include <netinet/in.h>*/
6 6
7#define EV_PROTOTYPES 1
8#include "EV/EVAPI.h"
9
10/* fix perl api breakage */ 7/* fix perl api breakage */
11#undef signal 8#undef signal
12#undef sigaction 9#undef sigaction
10
11#define EV_PROTOTYPES 1
12#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
13#define EV_H <ev.h>
14#include "EV/EVAPI.h"
13 15
14#define EV_SELECT_IS_WINSOCKET 0 16#define EV_SELECT_IS_WINSOCKET 0
15#ifdef _WIN32 17#ifdef _WIN32
16# define EV_SELECT_USE_FD_SET 0 18# define EV_SELECT_USE_FD_SET 0
17# define NFDBITS PERL_NFDBITS 19# define NFDBITS PERL_NFDBITS
18# define fd_mask Perl_fd_mask 20# define fd_mask Perl_fd_mask
19#endif 21#endif
20/* due to bugs in OS X we have to use libev/ explicitly here */ 22/* due to bugs in OS X we have to use libev/ explicitly here */
21#include "libev/ev.c" 23#include "libev/ev.c"
22#include "event.c"
23 24
24#ifndef _WIN32 25#ifndef _WIN32
25# include <pthread.h> 26# include <pthread.h>
26#endif 27#endif
27 28
29/* 5.10.0 */
30#ifndef SvREFCNT_inc_NN
31# define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv)
32#endif
33
34#if __GNUC__ >= 3
35# define expect(expr,value) __builtin_expect ((expr),(value))
36#else
37# define expect(expr,value) (expr)
38#endif
39
40#define expect_false(expr) expect ((expr) != 0, 0)
41#define expect_true(expr) expect ((expr) != 0, 1)
42
43#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop))
44
28#define WFLAG_KEEPALIVE 1 45#define WFLAG_KEEPALIVE 1
29 46
30#define UNREF(w) \ 47#define UNREF(w) \
31 if (!((w)->flags & WFLAG_KEEPALIVE) \ 48 if (!((w)->e_flags & WFLAG_KEEPALIVE) \
32 && !ev_is_active (w)) \ 49 && !ev_is_active (w)) \
33 ev_unref (); 50 ev_unref (e_loop (w));
34 51
35#define REF(w) \ 52#define REF(w) \
36 if (!((w)->flags & WFLAG_KEEPALIVE) \ 53 if (!((w)->e_flags & WFLAG_KEEPALIVE) \
37 && ev_is_active (w)) \ 54 && ev_is_active (w)) \
38 ev_ref (); 55 ev_ref (e_loop (w));
39 56
40#define START(type,w) \ 57#define START(type,w) \
41 do { \ 58 do { \
42 UNREF (w); \ 59 UNREF (w); \
43 ev_ ## type ## _start (w); \ 60 ev_ ## type ## _start (e_loop (w), w); \
44 } while (0) 61 } while (0)
45 62
46#define STOP(type,w) \ 63#define STOP(type,w) \
47 do { \ 64 do { \
48 REF (w); \ 65 REF (w); \
49 ev_ ## type ## _stop (w); \ 66 ev_ ## type ## _stop (e_loop (w), w); \
50 } while (0) 67 } while (0)
51 68
52#define RESET(type,w,seta) \ 69#define RESET(type,w,seta) \
53 do { \ 70 do { \
54 int active = ev_is_active (w); \ 71 int active = ev_is_active (w); \
57 if (active) START (type, w); \ 74 if (active) START (type, w); \
58 } while (0) 75 } while (0)
59 76
60typedef int Signal; 77typedef int Signal;
61 78
79static SV *default_loop_sv;
80
62static struct EVAPI evapi; 81static struct EVAPI evapi;
63 82
64static HV 83static HV
84 *stash_loop,
65 *stash_watcher, 85 *stash_watcher,
66 *stash_io, 86 *stash_io,
67 *stash_timer, 87 *stash_timer,
68 *stash_periodic, 88 *stash_periodic,
69 *stash_signal, 89 *stash_signal,
71 *stash_stat, 91 *stash_stat,
72 *stash_idle, 92 *stash_idle,
73 *stash_prepare, 93 *stash_prepare,
74 *stash_check, 94 *stash_check,
75 *stash_embed, 95 *stash_embed,
76 *stash_fork; 96 *stash_fork,
97 *stash_async;
77 98
78#ifndef SIG_SIZE 99#ifndef SIG_SIZE
79/* kudos to Slaven Rezic for the idea */ 100/* kudos to Slaven Rezic for the idea */
80static char sig_size [] = { SIG_NUM }; 101static char sig_size [] = { SIG_NUM };
81# define SIG_SIZE (sizeof (sig_size) + 1) 102# define SIG_SIZE (sizeof (sig_size) + 1)
101} 122}
102 123
103///////////////////////////////////////////////////////////////////////////// 124/////////////////////////////////////////////////////////////////////////////
104// Event 125// Event
105 126
106static void e_cb (ev_watcher *w, int revents); 127static void e_cb (EV_P_ ev_watcher *w, int revents);
107 128
108static int 129static int
109sv_fileno (SV *fh) 130sv_fileno (SV *fh)
110{ 131{
111 SvGETMAGIC (fh); 132 SvGETMAGIC (fh);
120 return SvIV (fh); 141 return SvIV (fh);
121 142
122 return -1; 143 return -1;
123} 144}
124 145
146static SV *
147e_get_cv (SV *cb_sv)
148{
149 HV *st;
150 GV *gvp;
151 CV *cv = sv_2cv (cb_sv, &st, &gvp, 0);
152
153 if (!cv)
154 croak ("EV watcher callback must be a CODE reference");
155
156 return (SV *)cv;
157}
158
125static void * 159static void *
126e_new (int size, SV *cb_sv) 160e_new (int size, SV *cb_sv, SV *loop)
127{ 161{
162 SV *cv = cb_sv ? e_get_cv (cb_sv) : 0;
128 ev_watcher *w; 163 ev_watcher *w;
129 SV *self = NEWSV (0, size); 164 SV *self = NEWSV (0, size);
130 SvPOK_only (self); 165 SvPOK_only (self);
131 SvCUR_set (self, size); 166 SvCUR_set (self, size);
132 167
133 w = (ev_watcher *)SvPVX (self); 168 w = (ev_watcher *)SvPVX (self);
134 169
135 ev_init (w, e_cb); 170 ev_init (w, cv ? e_cb : 0);
136 171
172 w->loop = SvREFCNT_inc (SvRV (loop));
137 w->flags = WFLAG_KEEPALIVE; 173 w->e_flags = WFLAG_KEEPALIVE;
138 w->data = 0; 174 w->data = 0;
139 w->fh = 0; 175 w->fh = 0;
140 w->cb_sv = newSVsv (cb_sv); 176 w->cb_sv = SvREFCNT_inc (cv);
141 w->self = self; 177 w->self = self;
142 178
143 return (void *)w; 179 return (void *)w;
144} 180}
145 181
146static void 182static void
147e_destroy (void *w_) 183e_destroy (void *w_)
148{ 184{
149 ev_watcher *w = (ev_watcher *)w_; 185 ev_watcher *w = (ev_watcher *)w_;
150 186
187 SvREFCNT_dec (w->loop ); w->loop = 0;
151 SvREFCNT_dec (w->fh ); w->fh = 0; 188 SvREFCNT_dec (w->fh ); w->fh = 0;
152 SvREFCNT_dec (w->cb_sv); w->cb_sv = 0; 189 SvREFCNT_dec (w->cb_sv); w->cb_sv = 0;
153 SvREFCNT_dec (w->data ); w->data = 0; 190 SvREFCNT_dec (w->data ); w->data = 0;
154} 191}
155 192
168 } 205 }
169 206
170 return rv; 207 return rv;
171} 208}
172 209
173static SV *sv_events_cache; 210static SV *sv_self_cache, *sv_events_cache;
174 211
175static void 212static void
176e_cb (ev_watcher *w, int revents) 213e_cb (EV_P_ ev_watcher *w, int revents)
177{ 214{
178 dSP; 215 dSP;
179 I32 mark = SP - PL_stack_base; 216 I32 mark = SP - PL_stack_base;
180 SV *sv_self, *sv_events; 217 SV *sv_self, *sv_events;
181 218
219 if (expect_true (sv_self_cache))
220 {
221 sv_self = sv_self_cache; sv_self_cache = 0;
222 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self));
223 }
224 else
225 {
182 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ 226 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */
227 SvREADONLY_on (sv_self);
228 }
183 229
184 if (sv_events_cache) 230 if (expect_true (sv_events_cache))
185 { 231 {
186 sv_events = sv_events_cache; sv_events_cache = 0; 232 sv_events = sv_events_cache; sv_events_cache = 0;
187 SvIV_set (sv_events, revents); 233 SvIV_set (sv_events, revents);
188 } 234 }
189 else 235 else
236 {
190 sv_events = newSViv (revents); 237 sv_events = newSViv (revents);
238 SvREADONLY_on (sv_events);
239 }
191 240
192 PUSHMARK (SP); 241 PUSHMARK (SP);
193 EXTEND (SP, 2); 242 EXTEND (SP, 2);
194 PUSHs (sv_self); 243 PUSHs (sv_self);
195 PUSHs (sv_events); 244 PUSHs (sv_events);
196 245
197 PUTBACK; 246 PUTBACK;
198 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 247 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
199 248
249 if (expect_false (sv_self_cache))
200 SvREFCNT_dec (sv_self); 250 SvREFCNT_dec (sv_self);
251 else
252 {
253 SvREFCNT_dec (SvRV (sv_self));
254 SvRV_set (sv_self, &PL_sv_undef);
255 sv_self_cache = sv_self;
256 }
201 257
202 if (sv_events_cache) 258 if (expect_false (sv_events_cache))
203 SvREFCNT_dec (sv_events); 259 SvREFCNT_dec (sv_events);
204 else 260 else
205 sv_events_cache = sv_events; 261 sv_events_cache = sv_events;
206 262
207 if (SvTRUE (ERRSV)) 263 if (SvTRUE (ERRSV))
354 }; 410 };
355 411
356 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 412 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
357 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 413 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
358 414
415 stash_loop = gv_stashpv ("EV::Loop" , 1);
359 stash_watcher = gv_stashpv ("EV::Watcher" , 1); 416 stash_watcher = gv_stashpv ("EV::Watcher" , 1);
360 stash_io = gv_stashpv ("EV::IO" , 1); 417 stash_io = gv_stashpv ("EV::IO" , 1);
361 stash_timer = gv_stashpv ("EV::Timer" , 1); 418 stash_timer = gv_stashpv ("EV::Timer" , 1);
362 stash_periodic = gv_stashpv ("EV::Periodic", 1); 419 stash_periodic = gv_stashpv ("EV::Periodic", 1);
363 stash_signal = gv_stashpv ("EV::Signal" , 1); 420 stash_signal = gv_stashpv ("EV::Signal" , 1);
365 stash_prepare = gv_stashpv ("EV::Prepare" , 1); 422 stash_prepare = gv_stashpv ("EV::Prepare" , 1);
366 stash_check = gv_stashpv ("EV::Check" , 1); 423 stash_check = gv_stashpv ("EV::Check" , 1);
367 stash_child = gv_stashpv ("EV::Child" , 1); 424 stash_child = gv_stashpv ("EV::Child" , 1);
368 stash_embed = gv_stashpv ("EV::Embed" , 1); 425 stash_embed = gv_stashpv ("EV::Embed" , 1);
369 stash_stat = gv_stashpv ("EV::Stat" , 1); 426 stash_stat = gv_stashpv ("EV::Stat" , 1);
427 stash_fork = gv_stashpv ("EV::Fork" , 1);
428 stash_async = gv_stashpv ("EV::Async" , 1);
370 429
371 { 430 {
372 SV *sv = perl_get_sv ("EV::API", TRUE); 431 SV *sv = perl_get_sv ("EV::API", TRUE);
373 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 432 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
374 433
375 /* the poor man's shared library emulator */ 434 /* the poor man's shared library emulator */
376 evapi.ver = EV_API_VERSION; 435 evapi.ver = EV_API_VERSION;
377 evapi.rev = EV_API_REVISION; 436 evapi.rev = EV_API_REVISION;
378 evapi.sv_fileno = sv_fileno; 437 evapi.sv_fileno = sv_fileno;
379 evapi.sv_signum = sv_signum; 438 evapi.sv_signum = sv_signum;
439 evapi.supported_backends = ev_supported_backends ();
440 evapi.recommended_backends = ev_recommended_backends ();
441 evapi.embeddable_backends = ev_embeddable_backends ();
442 evapi.time_ = ev_time;
443 evapi.sleep_ = ev_sleep;
444 evapi.loop_new = ev_loop_new;
445 evapi.loop_destroy = ev_loop_destroy;
446 evapi.loop_fork = ev_loop_fork;
447 evapi.loop_count = ev_loop_count;
380 evapi.now = ev_now; 448 evapi.now = ev_now;
449 evapi.now_update = ev_now_update;
381 evapi.backend = ev_backend; 450 evapi.backend = ev_backend;
382 evapi.unloop = ev_unloop; 451 evapi.unloop = ev_unloop;
383 evapi.ref = ev_ref; 452 evapi.ref = ev_ref;
384 evapi.unref = ev_unref; 453 evapi.unref = ev_unref;
385 evapi.time = ev_time;
386 evapi.loop = ev_loop; 454 evapi.loop = ev_loop;
387 evapi.once = ev_once; 455 evapi.once = ev_once;
388 evapi.io_start = ev_io_start; 456 evapi.io_start = ev_io_start;
389 evapi.io_stop = ev_io_stop; 457 evapi.io_stop = ev_io_stop;
390 evapi.timer_start = ev_timer_start; 458 evapi.timer_start = ev_timer_start;
391 evapi.timer_stop = ev_timer_stop; 459 evapi.timer_stop = ev_timer_stop;
392 evapi.timer_again = ev_timer_again; 460 evapi.timer_again = ev_timer_again;
393 evapi.periodic_start = ev_periodic_start; 461 evapi.periodic_start = ev_periodic_start;
394 evapi.periodic_stop = ev_periodic_stop; 462 evapi.periodic_stop = ev_periodic_stop;
395 evapi.signal_start = ev_signal_start; 463 evapi.signal_start = ev_signal_start;
396 evapi.signal_stop = ev_signal_stop; 464 evapi.signal_stop = ev_signal_stop;
397 evapi.idle_start = ev_idle_start; 465 evapi.idle_start = ev_idle_start;
398 evapi.idle_stop = ev_idle_stop; 466 evapi.idle_stop = ev_idle_stop;
399 evapi.prepare_start = ev_prepare_start; 467 evapi.prepare_start = ev_prepare_start;
400 evapi.prepare_stop = ev_prepare_stop; 468 evapi.prepare_stop = ev_prepare_stop;
401 evapi.check_start = ev_check_start; 469 evapi.check_start = ev_check_start;
402 evapi.check_stop = ev_check_stop; 470 evapi.check_stop = ev_check_stop;
403 evapi.child_start = ev_child_start; 471 evapi.child_start = ev_child_start;
404 evapi.child_stop = ev_child_stop; 472 evapi.child_stop = ev_child_stop;
405 evapi.stat_start = ev_stat_start; 473 evapi.stat_start = ev_stat_start;
406 evapi.stat_stop = ev_stat_stop; 474 evapi.stat_stop = ev_stat_stop;
407 evapi.stat_stat = ev_stat_stat; 475 evapi.stat_stat = ev_stat_stat;
476 evapi.embed_start = ev_embed_start;
477 evapi.embed_stop = ev_embed_stop;
478 evapi.embed_sweep = ev_embed_sweep;
479 evapi.fork_start = ev_fork_start;
480 evapi.fork_stop = ev_fork_stop;
481 evapi.async_start = ev_async_start;
482 evapi.async_stop = ev_async_stop;
483 evapi.async_send = ev_async_send;
408 evapi.clear_pending = ev_clear_pending; 484 evapi.clear_pending = ev_clear_pending;
409 evapi.invoke = ev_invoke; 485 evapi.invoke = ev_invoke;
410 486
411 sv_setiv (sv, (IV)&evapi); 487 sv_setiv (sv, (IV)&evapi);
412 SvREADONLY_on (sv); 488 SvREADONLY_on (sv);
413 } 489 }
414#ifndef _WIN32 490#ifndef _WIN32
415 pthread_atfork (0, 0, ev_default_fork); 491 pthread_atfork (0, 0, ev_default_fork);
416#endif 492#endif
417} 493}
418 494
495SV *ev_default_loop (unsigned int flags = 0)
496 CODE:
497{
498 if (!default_loop_sv)
499 {
500 evapi.default_loop = ev_default_loop (flags);
501
502 if (!evapi.default_loop)
503 XSRETURN_UNDEF;
504
505 default_loop_sv = sv_bless (newRV_noinc (newSViv (PTR2IV (evapi.default_loop))), stash_loop);
506 }
507
508 RETVAL = newSVsv (default_loop_sv);
509}
510 OUTPUT:
511 RETVAL
512
513void ev_default_destroy ()
514 CODE:
515 ev_default_destroy ();
516 SvREFCNT_dec (default_loop_sv);
517 default_loop_sv = 0;
518
519unsigned int ev_supported_backends ()
520
521unsigned int ev_recommended_backends ()
522
523unsigned int ev_embeddable_backends ()
524
525void ev_sleep (NV interval)
526
527NV ev_time ()
528
419NV ev_now () 529NV ev_now ()
530 C_ARGS: evapi.default_loop
531
532void ev_now_update ()
533 C_ARGS: evapi.default_loop
420 534
421unsigned int ev_backend () 535unsigned int ev_backend ()
422 536 C_ARGS: evapi.default_loop
423NV ev_time ()
424
425unsigned int ev_default_loop (unsigned int flags = ev_supported_backends ())
426 537
427unsigned int ev_loop_count () 538unsigned int ev_loop_count ()
539 C_ARGS: evapi.default_loop
540
541void ev_set_io_collect_interval (NV interval)
542 C_ARGS: evapi.default_loop, interval
543
544void ev_set_timeout_collect_interval (NV interval)
545 C_ARGS: evapi.default_loop, interval
428 546
429void ev_loop (int flags = 0) 547void ev_loop (int flags = 0)
548 C_ARGS: evapi.default_loop, flags
430 549
431void ev_unloop (int how = 1) 550void ev_unloop (int how = EVUNLOOP_ONE)
551 C_ARGS: evapi.default_loop, how
432 552
433void ev_feed_fd_event (int fd, int revents = EV_NONE) 553void ev_feed_fd_event (int fd, int revents = EV_NONE)
554 C_ARGS: evapi.default_loop, fd, revents
434 555
435void ev_feed_signal_event (SV *signal) 556void ev_feed_signal_event (SV *signal)
436 CODE: 557 CODE:
437{ 558{
438 Signal signum = sv_signum (signal); 559 Signal signum = sv_signum (signal);
439 CHECK_SIG (signal, signum); 560 CHECK_SIG (signal, signum);
440 561
441 ev_feed_signal_event (EV_DEFAULT_ signum); 562 ev_feed_signal_event (evapi.default_loop, signum);
442} 563}
443 564
444ev_io *io (SV *fh, int events, SV *cb) 565ev_io *io (SV *fh, int events, SV *cb)
445 ALIAS: 566 ALIAS:
446 io_ns = 1 567 io_ns = 1
447 CODE: 568 CODE:
448{ 569{
449 int fd = sv_fileno (fh); 570 int fd = sv_fileno (fh);
450 CHECK_FD (fh, fd); 571 CHECK_FD (fh, fd);
451 572
452 RETVAL = e_new (sizeof (ev_io), cb); 573 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv);
453 RETVAL->fh = newSVsv (fh); 574 RETVAL->fh = newSVsv (fh);
454 ev_io_set (RETVAL, fd, events); 575 ev_io_set (RETVAL, fd, events);
455 if (!ix) START (io, RETVAL); 576 if (!ix) START (io, RETVAL);
456} 577}
457 OUTPUT: 578 OUTPUT:
461 ALIAS: 582 ALIAS:
462 timer_ns = 1 583 timer_ns = 1
463 INIT: 584 INIT:
464 CHECK_REPEAT (repeat); 585 CHECK_REPEAT (repeat);
465 CODE: 586 CODE:
466 RETVAL = e_new (sizeof (ev_timer), cb); 587 RETVAL = e_new (sizeof (ev_timer), cb, default_loop_sv);
467 ev_timer_set (RETVAL, after, repeat); 588 ev_timer_set (RETVAL, after, repeat);
468 if (!ix) START (timer, RETVAL); 589 if (!ix) START (timer, RETVAL);
469 OUTPUT: 590 OUTPUT:
470 RETVAL 591 RETVAL
471 592
475 INIT: 596 INIT:
476 CHECK_REPEAT (interval); 597 CHECK_REPEAT (interval);
477 CODE: 598 CODE:
478{ 599{
479 ev_periodic *w; 600 ev_periodic *w;
480 w = e_new (sizeof (ev_periodic), cb); 601 w = e_new (sizeof (ev_periodic), cb, default_loop_sv);
481 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 602 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
482 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 603 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0);
483 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 604 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
484 if (!ix) START (periodic, w); 605 if (!ix) START (periodic, w);
485} 606}
492 CODE: 613 CODE:
493{ 614{
494 Signal signum = sv_signum (signal); 615 Signal signum = sv_signum (signal);
495 CHECK_SIG (signal, signum); 616 CHECK_SIG (signal, signum);
496 617
497 RETVAL = e_new (sizeof (ev_signal), cb); 618 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv);
498 ev_signal_set (RETVAL, signum); 619 ev_signal_set (RETVAL, signum);
499 if (!ix) START (signal, RETVAL); 620 if (!ix) START (signal, RETVAL);
500} 621}
501 OUTPUT: 622 OUTPUT:
502 RETVAL 623 RETVAL
503 624
504ev_idle *idle (SV *cb) 625ev_idle *idle (SV *cb)
505 ALIAS: 626 ALIAS:
506 idle_ns = 1 627 idle_ns = 1
507 CODE: 628 CODE:
508 RETVAL = e_new (sizeof (ev_idle), cb); 629 RETVAL = e_new (sizeof (ev_idle), cb, default_loop_sv);
509 ev_idle_set (RETVAL); 630 ev_idle_set (RETVAL);
510 if (!ix) START (idle, RETVAL); 631 if (!ix) START (idle, RETVAL);
511 OUTPUT: 632 OUTPUT:
512 RETVAL 633 RETVAL
513 634
514ev_prepare *prepare (SV *cb) 635ev_prepare *prepare (SV *cb)
515 ALIAS: 636 ALIAS:
516 prepare_ns = 1 637 prepare_ns = 1
517 CODE: 638 CODE:
518 RETVAL = e_new (sizeof (ev_prepare), cb); 639 RETVAL = e_new (sizeof (ev_prepare), cb, default_loop_sv);
519 ev_prepare_set (RETVAL); 640 ev_prepare_set (RETVAL);
520 if (!ix) START (prepare, RETVAL); 641 if (!ix) START (prepare, RETVAL);
521 OUTPUT: 642 OUTPUT:
522 RETVAL 643 RETVAL
523 644
524ev_check *check (SV *cb) 645ev_check *check (SV *cb)
525 ALIAS: 646 ALIAS:
526 check_ns = 1 647 check_ns = 1
527 CODE: 648 CODE:
528 RETVAL = e_new (sizeof (ev_check), cb); 649 RETVAL = e_new (sizeof (ev_check), cb, default_loop_sv);
529 ev_check_set (RETVAL); 650 ev_check_set (RETVAL);
530 if (!ix) START (check, RETVAL); 651 if (!ix) START (check, RETVAL);
531 OUTPUT: 652 OUTPUT:
532 RETVAL 653 RETVAL
533 654
655ev_fork *fork (SV *cb)
656 ALIAS:
657 fork_ns = 1
658 CODE:
659 RETVAL = e_new (sizeof (ev_fork), cb, default_loop_sv);
660 ev_fork_set (RETVAL);
661 if (!ix) START (fork, RETVAL);
662 OUTPUT:
663 RETVAL
664
534ev_child *child (int pid, SV *cb) 665ev_child *child (int pid, int trace, SV *cb)
535 ALIAS: 666 ALIAS:
536 child_ns = 1 667 child_ns = 1
537 CODE: 668 CODE:
538 RETVAL = e_new (sizeof (ev_child), cb); 669 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv);
539 ev_child_set (RETVAL, pid); 670 ev_child_set (RETVAL, pid, trace);
540 if (!ix) START (child, RETVAL); 671 if (!ix) START (child, RETVAL);
541 OUTPUT: 672 OUTPUT:
542 RETVAL 673 RETVAL
543 674
544ev_stat *stat (SV *path, NV interval, SV *cb) 675ev_stat *stat (SV *path, NV interval, SV *cb)
545 ALIAS: 676 ALIAS:
546 stat_ns = 1 677 stat_ns = 1
547 CODE: 678 CODE:
548 RETVAL = e_new (sizeof (ev_stat), cb); 679 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv);
549 RETVAL->fh = newSVsv (path); 680 RETVAL->fh = newSVsv (path);
550 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 681 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval);
551 if (!ix) START (stat, RETVAL); 682 if (!ix) START (stat, RETVAL);
552 OUTPUT: 683 OUTPUT:
553 RETVAL 684 RETVAL
554 685
686ev_embed *embed (struct ev_loop *loop, SV *cb = 0)
687 ALIAS:
688 embed_ns = 1
689 CODE:
690{
691 if (!(ev_backend (loop) & ev_embeddable_backends ()))
692 croak ("passed loop is not embeddable via EV::embed,");
693
694 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv);
695 RETVAL->fh = newSVsv (ST (0));
696 ev_embed_set (RETVAL, loop);
697 if (!ix) START (embed, RETVAL);
698}
699 OUTPUT:
700 RETVAL
701
702ev_async *async (SV *cb)
703 ALIAS:
704 async_ns = 1
705 CODE:
706 RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv);
707 ev_async_set (RETVAL);
708 if (!ix) START (async, RETVAL);
709 OUTPUT:
710 RETVAL
711
555void once (SV *fh, int events, SV *timeout, SV *cb) 712void once (SV *fh, int events, SV *timeout, SV *cb)
556 CODE: 713 CODE:
557 ev_once ( 714 ev_once (
715 evapi.default_loop,
558 sv_fileno (fh), events, 716 sv_fileno (fh), events,
559 SvOK (timeout) ? SvNV (timeout) : -1., 717 SvOK (timeout) ? SvNV (timeout) : -1.,
560 e_once_cb, 718 e_once_cb,
561 newSVsv (cb) 719 newSVsv (cb)
562 ); 720 );
568int ev_is_active (ev_watcher *w) 726int ev_is_active (ev_watcher *w)
569 727
570int ev_is_pending (ev_watcher *w) 728int ev_is_pending (ev_watcher *w)
571 729
572void ev_invoke (ev_watcher *w, int revents = EV_NONE) 730void ev_invoke (ev_watcher *w, int revents = EV_NONE)
731 C_ARGS: e_loop (w), w, revents
573 732
574int ev_clear_pending (ev_watcher *w) 733int ev_clear_pending (ev_watcher *w)
734 C_ARGS: e_loop (w), w
575 735
576void ev_feed_event (ev_watcher *w, int revents = EV_NONE) 736void ev_feed_event (ev_watcher *w, int revents = EV_NONE)
737 C_ARGS: e_loop (w), w, revents
577 738
578int keepalive (ev_watcher *w, int new_value = 0) 739int keepalive (ev_watcher *w, int new_value = 0)
579 CODE: 740 CODE:
580{ 741{
581 RETVAL = w->flags & WFLAG_KEEPALIVE; 742 RETVAL = w->e_flags & WFLAG_KEEPALIVE;
582 new_value = new_value ? WFLAG_KEEPALIVE : 0; 743 new_value = new_value ? WFLAG_KEEPALIVE : 0;
583 744
584 if (items > 1 && ((new_value ^ w->flags) & WFLAG_KEEPALIVE)) 745 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE))
585 { 746 {
586 REF (w); 747 REF (w);
587 w->flags = (w->flags & ~WFLAG_KEEPALIVE) | new_value; 748 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value;
588 UNREF (w); 749 UNREF (w);
589 } 750 }
590} 751}
591 OUTPUT: 752 OUTPUT:
592 RETVAL 753 RETVAL
593 754
594SV *cb (ev_watcher *w, SV *new_cb = 0) 755SV *cb (ev_watcher *w, SV *new_cb = 0)
595 CODE: 756 CODE:
596{ 757{
597 RETVAL = newSVsv (w->cb_sv);
598
599 if (items > 1) 758 if (items > 1)
600 sv_setsv (w->cb_sv, new_cb); 759 {
760 new_cb = e_get_cv (new_cb);
761 RETVAL = newRV_noinc (w->cb_sv);
762 w->cb_sv = SvREFCNT_inc (new_cb);
763 }
764 else
765 RETVAL = newRV_inc (w->cb_sv);
601} 766}
602 OUTPUT: 767 OUTPUT:
603 RETVAL 768 RETVAL
604 769
605SV *data (ev_watcher *w, SV *new_data = 0) 770SV *data (ev_watcher *w, SV *new_data = 0)
611 { 776 {
612 SvREFCNT_dec (w->data); 777 SvREFCNT_dec (w->data);
613 w->data = newSVsv (new_data); 778 w->data = newSVsv (new_data);
614 } 779 }
615} 780}
781 OUTPUT:
782 RETVAL
783
784SV *loop (ev_watcher *w)
785 CODE:
786 RETVAL = newRV_inc (w->loop);
616 OUTPUT: 787 OUTPUT:
617 RETVAL 788 RETVAL
618 789
619int priority (ev_watcher *w, int new_priority = 0) 790int priority (ev_watcher *w, int new_priority = 0)
620 CODE: 791 CODE:
758void ev_timer_again (ev_timer *w) 929void ev_timer_again (ev_timer *w)
759 INIT: 930 INIT:
760 CHECK_REPEAT (w->repeat); 931 CHECK_REPEAT (w->repeat);
761 CODE: 932 CODE:
762 REF (w); 933 REF (w);
763 ev_timer_again (w); 934 ev_timer_again (e_loop (w), w);
764 UNREF (w); 935 UNREF (w);
765 936
766void DESTROY (ev_timer *w) 937void DESTROY (ev_timer *w)
767 CODE: 938 CODE:
768 STOP (timer, w); 939 STOP (timer, w);
772 INIT: 943 INIT:
773 CHECK_REPEAT (repeat); 944 CHECK_REPEAT (repeat);
774 CODE: 945 CODE:
775 RESET (timer, w, (w, after, repeat)); 946 RESET (timer, w, (w, after, repeat));
776 947
777NV at (ev_timer *w)
778 CODE:
779 RETVAL = w->at;
780 OUTPUT:
781 RETVAL
782
783MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 948MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
784 949
785void ev_periodic_start (ev_periodic *w) 950void ev_periodic_start (ev_periodic *w)
786 INIT: 951 INIT:
787 CHECK_REPEAT (w->interval); 952 CHECK_REPEAT (w->interval);
793 STOP (periodic, w); 958 STOP (periodic, w);
794 959
795void ev_periodic_again (ev_periodic *w) 960void ev_periodic_again (ev_periodic *w)
796 CODE: 961 CODE:
797 REF (w); 962 REF (w);
798 ev_periodic_again (w); 963 ev_periodic_again (e_loop (w), w);
799 UNREF (w); 964 UNREF (w);
800 965
801void DESTROY (ev_periodic *w) 966void DESTROY (ev_periodic *w)
802 CODE: 967 CODE:
803 STOP (periodic, w); 968 STOP (periodic, w);
814 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 979 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0));
815} 980}
816 981
817NV at (ev_periodic *w) 982NV at (ev_periodic *w)
818 CODE: 983 CODE:
819 RETVAL = w->at; 984 RETVAL = ev_periodic_at (w);
820 OUTPUT: 985 OUTPUT:
821 RETVAL 986 RETVAL
822 987
823MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 988MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
824 989
833void DESTROY (ev_idle *w) 998void DESTROY (ev_idle *w)
834 CODE: 999 CODE:
835 STOP (idle, w); 1000 STOP (idle, w);
836 e_destroy (w); 1001 e_destroy (w);
837 1002
838MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_check_ 1003MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_
839 1004
840void ev_prepare_start (ev_prepare *w) 1005void ev_prepare_start (ev_prepare *w)
841 CODE: 1006 CODE:
842 START (prepare, w); 1007 START (prepare, w);
843 1008
863void DESTROY (ev_check *w) 1028void DESTROY (ev_check *w)
864 CODE: 1029 CODE:
865 STOP (check, w); 1030 STOP (check, w);
866 e_destroy (w); 1031 e_destroy (w);
867 1032
1033MODULE = EV PACKAGE = EV::Fork PREFIX = ev_fork_
1034
1035void ev_fork_start (ev_fork *w)
1036 CODE:
1037 START (fork, w);
1038
1039void ev_fork_stop (ev_fork *w)
1040 CODE:
1041 STOP (fork, w);
1042
1043void DESTROY (ev_fork *w)
1044 CODE:
1045 STOP (fork, w);
1046 e_destroy (w);
1047
868MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 1048MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
869 1049
870void ev_child_start (ev_child *w) 1050void ev_child_start (ev_child *w)
871 CODE: 1051 CODE:
872 START (child, w); 1052 START (child, w);
878void DESTROY (ev_child *w) 1058void DESTROY (ev_child *w)
879 CODE: 1059 CODE:
880 STOP (child, w); 1060 STOP (child, w);
881 e_destroy (w); 1061 e_destroy (w);
882 1062
883void set (ev_child *w, int pid) 1063void set (ev_child *w, int pid, int trace)
884 CODE: 1064 CODE:
885 RESET (child, w, (w, pid)); 1065 RESET (child, w, (w, pid, trace));
886 1066
887int pid (ev_child *w, int new_pid = 0)
888 CODE:
889{
890 RETVAL = w->pid;
891
892 if (items > 1)
893 RESET (child, w, (w, new_pid));
894}
895 OUTPUT:
896 RETVAL
897
898
899int rstatus (ev_child *w) 1067int pid (ev_child *w)
900 ALIAS: 1068 ALIAS:
901 rpid = 1 1069 rpid = 1
1070 rstatus = 2
902 CODE: 1071 CODE:
903 RETVAL = ix ? w->rpid : w->rstatus; 1072 RETVAL = ix == 0 ? w->pid
1073 : ix == 1 ? w->rpid
1074 : w->rstatus;
904 OUTPUT: 1075 OUTPUT:
905 RETVAL 1076 RETVAL
906 1077
907MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ 1078MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_
908 1079
959 PPCODE: 1130 PPCODE:
960{ 1131{
961 ev_statdata *s = ix ? &w->attr : &w->prev; 1132 ev_statdata *s = ix ? &w->attr : &w->prev;
962 1133
963 if (ix == 1) 1134 if (ix == 1)
964 ev_stat_stat (w); 1135 ev_stat_stat (e_loop (w), w);
965 else if (!s->st_nlink) 1136 else if (!s->st_nlink)
966 errno = ENOENT; 1137 errno = ENOENT;
967 1138
968 PL_statcache.st_dev = s->st_nlink; 1139 PL_statcache.st_dev = s->st_nlink;
969 PL_statcache.st_ino = s->st_ino; 1140 PL_statcache.st_ino = s->st_ino;
996 PUSHs (sv_2mortal (newSVuv (4096))); 1167 PUSHs (sv_2mortal (newSVuv (4096)));
997 PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096)))); 1168 PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096))));
998 } 1169 }
999} 1170}
1000 1171
1172MODULE = EV PACKAGE = EV::Embed PREFIX = ev_embed_
1173
1174void ev_embed_start (ev_embed *w)
1175 CODE:
1176 START (embed, w);
1177
1178void ev_embed_stop (ev_embed *w)
1179 CODE:
1180 STOP (embed, w);
1181
1182void DESTROY (ev_embed *w)
1183 CODE:
1184 STOP (embed, w);
1185 e_destroy (w);
1186
1187void set (ev_embed *w, struct ev_loop *loop)
1188 CODE:
1189{
1190 sv_setsv (w->fh, ST (1));
1191 RESET (embed, w, (w, loop));
1192}
1193
1194SV *other (ev_embed *w)
1195 CODE:
1196 RETVAL = newSVsv (w->fh);
1197 OUTPUT:
1198 RETVAL
1199
1200void ev_embed_sweep (ev_embed *w)
1201 C_ARGS: e_loop (w), w
1202
1203MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_
1204
1205void ev_async_start (ev_async *w)
1206 CODE:
1207 START (async, w);
1208
1209void ev_async_stop (ev_async *w)
1210 CODE:
1211 STOP (async, w);
1212
1213void DESTROY (ev_async *w)
1214 CODE:
1215 STOP (async, w);
1216 e_destroy (w);
1217
1218void ev_async_send (ev_async *w)
1219 C_ARGS: e_loop (w), w
1220
1221SV *ev_async_async_pending (ev_async *w)
1222 CODE:
1223 RETVAL = boolSV (ev_async_pending (w));
1224 OUTPUT:
1225 RETVAL
1226
1227MODULE = EV PACKAGE = EV::Loop PREFIX = ev_
1228
1229SV *new (SV *klass, unsigned int flags = 0)
1230 CODE:
1231{
1232 struct ev_loop *loop = ev_loop_new (flags);
1233
1234 if (!loop)
1235 XSRETURN_UNDEF;
1236
1237 RETVAL = sv_bless (newRV_noinc (newSViv (PTR2IV (loop))), stash_loop);
1238}
1239 OUTPUT:
1240 RETVAL
1241
1242void DESTROY (struct ev_loop *loop)
1243 CODE:
1244 if (loop != evapi.default_loop) /* global destruction sucks */
1245 ev_loop_destroy (loop);
1246
1247void ev_loop_fork (struct ev_loop *loop)
1248
1249void ev_loop_verify (struct ev_loop *loop)
1250
1251NV ev_now (struct ev_loop *loop)
1252
1253void ev_now_update (struct ev_loop *loop)
1254
1255void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1256
1257void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1258
1259unsigned int ev_backend (struct ev_loop *loop)
1260
1261unsigned int ev_loop_count (struct ev_loop *loop)
1262
1263void ev_loop (struct ev_loop *loop, int flags = 0)
1264
1265void ev_unloop (struct ev_loop *loop, int how = 1)
1266
1267void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1268
1001#if 0 1269#if 0
1002 1270
1003MODULE = EV PACKAGE = EV::HTTP PREFIX = evhttp_ 1271void ev_feed_signal_event (struct ev_loop *loop, SV *signal)
1004 1272 CODE:
1005BOOT:
1006{ 1273{
1007 HV *stash = gv_stashpv ("EV::HTTP", 1); 1274 Signal signum = sv_signum (signal);
1275 CHECK_SIG (signal, signum);
1008 1276
1009 static const struct { 1277 ev_feed_signal_event (loop, signum);
1010 const char *name;
1011 IV iv;
1012 } *civ, const_iv[] = {
1013# define const_iv(pfx, name) { # name, (IV) pfx ## name },
1014 const_iv (HTTP_, OK)
1015 const_iv (HTTP_, NOCONTENT)
1016 const_iv (HTTP_, MOVEPERM)
1017 const_iv (HTTP_, MOVETEMP)
1018 const_iv (HTTP_, NOTMODIFIED)
1019 const_iv (HTTP_, BADREQUEST)
1020 const_iv (HTTP_, NOTFOUND)
1021 const_iv (HTTP_, SERVUNAVAIL)
1022 const_iv (EVHTTP_, REQ_OWN_CONNECTION)
1023 const_iv (EVHTTP_, PROXY_REQUEST)
1024 const_iv (EVHTTP_, REQ_GET)
1025 const_iv (EVHTTP_, REQ_POST)
1026 const_iv (EVHTTP_, REQ_HEAD)
1027 const_iv (EVHTTP_, REQUEST)
1028 const_iv (EVHTTP_, RESPONSE)
1029 };
1030
1031 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1032 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1033} 1278}
1034
1035MODULE = EV PACKAGE = EV::HTTP::Request PREFIX = evhttp_request_
1036
1037#HttpRequest new (SV *klass, SV *cb)
1038
1039#void DESTROY (struct evhttp_request *req);
1040 1279
1041#endif 1280#endif
1042 1281
1282ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb)
1283 ALIAS:
1284 io_ns = 1
1285 CODE:
1286{
1287 int fd = sv_fileno (fh);
1288 CHECK_FD (fh, fd);
1043 1289
1290 RETVAL = e_new (sizeof (ev_io), cb, ST (0));
1291 RETVAL->fh = newSVsv (fh);
1292 ev_io_set (RETVAL, fd, events);
1293 if (!ix) START (io, RETVAL);
1294}
1295 OUTPUT:
1296 RETVAL
1044 1297
1298ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb)
1299 ALIAS:
1300 timer_ns = 1
1301 INIT:
1302 CHECK_REPEAT (repeat);
1303 CODE:
1304 RETVAL = e_new (sizeof (ev_timer), cb, ST (0));
1305 ev_timer_set (RETVAL, after, repeat);
1306 if (!ix) START (timer, RETVAL);
1307 OUTPUT:
1308 RETVAL
1045 1309
1310SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb)
1311 ALIAS:
1312 periodic_ns = 1
1313 INIT:
1314 CHECK_REPEAT (interval);
1315 CODE:
1316{
1317 ev_periodic *w;
1318 w = e_new (sizeof (ev_periodic), cb, ST (0));
1319 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1320 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0);
1321 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1322 if (!ix) START (periodic, w);
1323}
1324 OUTPUT:
1325 RETVAL
1046 1326
1327#if 0
1047 1328
1329ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb)
1330 ALIAS:
1331 signal_ns = 1
1332 CODE:
1333{
1334 Signal signum = sv_signum (signal);
1335 CHECK_SIG (signal, signum);
1048 1336
1337 RETVAL = e_new (sizeof (ev_signal), cb, ST (0));
1338 ev_signal_set (RETVAL, signum);
1339 if (!ix) START (signal, RETVAL);
1340}
1341 OUTPUT:
1342 RETVAL
1049 1343
1344#endif
1345
1346ev_idle *idle (struct ev_loop *loop, SV *cb)
1347 ALIAS:
1348 idle_ns = 1
1349 CODE:
1350 RETVAL = e_new (sizeof (ev_idle), cb, ST (0));
1351 ev_idle_set (RETVAL);
1352 if (!ix) START (idle, RETVAL);
1353 OUTPUT:
1354 RETVAL
1355
1356ev_prepare *prepare (struct ev_loop *loop, SV *cb)
1357 ALIAS:
1358 prepare_ns = 1
1359 CODE:
1360 RETVAL = e_new (sizeof (ev_prepare), cb, ST (0));
1361 ev_prepare_set (RETVAL);
1362 if (!ix) START (prepare, RETVAL);
1363 OUTPUT:
1364 RETVAL
1365
1366ev_check *check (struct ev_loop *loop, SV *cb)
1367 ALIAS:
1368 check_ns = 1
1369 CODE:
1370 RETVAL = e_new (sizeof (ev_check), cb, ST (0));
1371 ev_check_set (RETVAL);
1372 if (!ix) START (check, RETVAL);
1373 OUTPUT:
1374 RETVAL
1375
1376ev_fork *fork (struct ev_loop *loop, SV *cb)
1377 ALIAS:
1378 fork_ns = 1
1379 CODE:
1380 RETVAL = e_new (sizeof (ev_fork), cb, ST (0));
1381 ev_fork_set (RETVAL);
1382 if (!ix) START (fork, RETVAL);
1383 OUTPUT:
1384 RETVAL
1385
1386ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1387 ALIAS:
1388 child_ns = 1
1389 CODE:
1390 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1391 ev_child_set (RETVAL, pid, trace);
1392 if (!ix) START (child, RETVAL);
1393 OUTPUT:
1394 RETVAL
1395
1396ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1397 ALIAS:
1398 stat_ns = 1
1399 CODE:
1400 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1401 RETVAL->fh = newSVsv (path);
1402 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval);
1403 if (!ix) START (stat, RETVAL);
1404 OUTPUT:
1405 RETVAL
1406
1407ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0)
1408 ALIAS:
1409 embed_ns = 1
1410 CODE:
1411{
1412 if (!(ev_backend (other) & ev_embeddable_backends ()))
1413 croak ("passed loop is not embeddable via EV::embed,");
1414
1415 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1416 RETVAL->fh = newSVsv (ST (1));
1417 ev_embed_set (RETVAL, other);
1418 if (!ix) START (embed, RETVAL);
1419}
1420 OUTPUT:
1421 RETVAL
1422
1423ev_async *async (struct ev_loop *loop, SV *cb)
1424 ALIAS:
1425 async_ns = 1
1426 CODE:
1427 RETVAL = e_new (sizeof (ev_async), cb, ST (0));
1428 ev_async_set (RETVAL);
1429 if (!ix) START (async, RETVAL);
1430 OUTPUT:
1431 RETVAL
1432
1433void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1434 CODE:
1435 ev_once (
1436 loop,
1437 sv_fileno (fh), events,
1438 SvOK (timeout) ? SvNV (timeout) : -1.,
1439 e_once_cb,
1440 newSVsv (cb)
1441 );
1442

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines