ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV.xs
Revision: 1.138
Committed: Wed Apr 14 00:17:22 2010 UTC (14 years, 1 month ago) by root
Branch: MAIN
Changes since 1.137: +40 -36 lines
Log Message:
strict(er?) aliasing

File Contents

# Content
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
5 /* fix perl api breakage */
6 #undef signal
7 #undef sigaction
8
9 #include "schmorp.h"
10
11 /* old API compatibility */
12 static int
13 sv_fileno (SV *fh)
14 {
15 return s_fileno (fh, 0);
16 }
17
18 #define EV_STANDALONE 1
19 #define EV_PROTOTYPES 1
20 #define EV_USE_NANOSLEEP EV_USE_MONOTONIC
21 #define EV_H <ev.h>
22 #define EV_CONFIG_H error
23 #include "EV/EVAPI.h"
24
25 #define EV_SELECT_IS_WINSOCKET 0
26 #ifdef _WIN32
27 # define EV_SELECT_USE_FD_SET 0
28 # define NFDBITS PERL_NFDBITS
29 # define fd_mask Perl_fd_mask
30 #endif
31 /* due to bugs in OS X we have to use libev/ explicitly here */
32 #include "libev/ev.c"
33
34 #ifndef _WIN32
35 # include <pthread.h>
36 #endif
37
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
43
44 #define WFLAG_KEEPALIVE 1
45 #define WFLAG_UNREFED 2 /* has been unref'ed */
46
47 #define UNREF(w) \
48 if (!(e_flags (w) & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \
49 && ev_is_active (w)) \
50 { \
51 ev_unref (e_loop (w)); \
52 e_flags (w) |= WFLAG_UNREFED; \
53 }
54
55 #define REF(w) \
56 if (e_flags (w) & WFLAG_UNREFED) \
57 { \
58 e_flags (w) &= ~WFLAG_UNREFED; \
59 ev_ref (e_loop (w)); \
60 }
61
62 #define START(type,w) \
63 do { \
64 ev_ ## type ## _start (e_loop (w), w); \
65 UNREF (w); \
66 } while (0)
67
68 #define STOP(type,w) \
69 do { \
70 REF (w); \
71 ev_ ## type ## _stop (e_loop (w), w); \
72 } while (0)
73
74 #define RESET(type,w,seta) \
75 do { \
76 int active = ev_is_active (w); \
77 if (active) STOP (type, w); \
78 ev_ ## type ## _set seta; \
79 if (active) START (type, w); \
80 } while (0)
81
82 typedef int Signal;
83
84 /* horrible... */
85 #define CHECK_SIGNAL_CAN_START(w) \
86 do { \
87 /* dive into the internals of libev to avoid aborting in libev */ \
88 if (signals [(w)->signum - 1].loop \
89 && signals [(w)->signum - 1].loop != e_loop (w)) \
90 croak ("unable to start signal watcher, signal %d already registered in another loop", w->signum); \
91 } while (0)
92
93 #define START_SIGNAL(w) \
94 do { \
95 CHECK_SIGNAL_CAN_START (w); \
96 START (signal, w); \
97 } while (0) \
98
99 #define RESET_SIGNAL(w,seta) \
100 do { \
101 int active = ev_is_active (w); \
102 if (active) STOP (signal, w); \
103 ev_ ## signal ## _set seta; \
104 if (active) START_SIGNAL (w); \
105 } while (0)
106
107 static SV *default_loop_sv;
108
109 static struct EVAPI evapi;
110
111 static HV
112 *stash_loop,
113 *stash_watcher,
114 *stash_io,
115 *stash_timer,
116 *stash_periodic,
117 *stash_signal,
118 *stash_child,
119 *stash_stat,
120 *stash_idle,
121 *stash_prepare,
122 *stash_check,
123 *stash_embed,
124 *stash_fork,
125 *stash_async;
126
127 /////////////////////////////////////////////////////////////////////////////
128 // Event
129
130 static void e_cb (EV_P_ ev_watcher *w, int revents);
131
132 void *
133 e_new (int size, SV *cb_sv, SV *loop)
134 {
135 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0;
136 ev_watcher *w;
137 SV *self = NEWSV (0, size);
138 SvPOK_only (self);
139 SvCUR_set (self, size);
140
141 w = (ev_watcher *)SvPVX (self);
142
143 ev_init (w, cv ? e_cb : 0);
144
145 w->loop = SvREFCNT_inc (SvRV (loop));
146 w->e_flags = WFLAG_KEEPALIVE;
147 w->data = 0;
148 w->fh = 0;
149 w->cb_sv = SvREFCNT_inc (cv);
150 w->self = self;
151
152 return (void *)w;
153 }
154
155 static void
156 e_destroy (void *w_)
157 {
158 ev_watcher *w = (ev_watcher *)w_;
159
160 SvREFCNT_dec (w->loop ); w->loop = 0;
161 SvREFCNT_dec (w->fh ); w->fh = 0;
162 SvREFCNT_dec (w->cb_sv); w->cb_sv = 0;
163 SvREFCNT_dec (w->data ); w->data = 0;
164 }
165
166 static SV *
167 e_bless (ev_watcher *w, HV *stash)
168 {
169 SV *rv;
170
171 if (SvOBJECT (w->self))
172 rv = newRV_inc (w->self);
173 else
174 {
175 rv = newRV_noinc (w->self);
176 sv_bless (rv, stash);
177 SvREADONLY_on (w->self);
178 }
179
180 return rv;
181 }
182
183 static SV *sv_self_cache, *sv_events_cache;
184
185 static void
186 e_cb (EV_P_ ev_watcher *w, int revents)
187 {
188 dSP;
189 I32 mark = SP - PL_stack_base;
190 SV *sv_self, *sv_events;
191
192 /* libev might have stopped the watcher */
193 if (expect_false (w->e_flags & WFLAG_UNREFED)
194 && !ev_is_active (w))
195 REF (w);
196
197 if (expect_true (sv_self_cache))
198 {
199 sv_self = sv_self_cache; sv_self_cache = 0;
200 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self));
201 }
202 else
203 {
204 sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */
205 SvREADONLY_on (sv_self);
206 }
207
208 if (expect_true (sv_events_cache))
209 {
210 sv_events = sv_events_cache; sv_events_cache = 0;
211 SvIV_set (sv_events, revents);
212 }
213 else
214 {
215 sv_events = newSViv (revents);
216 SvREADONLY_on (sv_events);
217 }
218
219 PUSHMARK (SP);
220 EXTEND (SP, 2);
221 PUSHs (sv_self);
222 PUSHs (sv_events);
223
224 PUTBACK;
225 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
226
227 if (expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache))
228 SvREFCNT_dec (sv_self);
229 else
230 {
231 SvREFCNT_dec (SvRV (sv_self));
232 SvRV_set (sv_self, &PL_sv_undef);
233 sv_self_cache = sv_self;
234 }
235
236 if (expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache))
237 SvREFCNT_dec (sv_events);
238 else
239 sv_events_cache = sv_events;
240
241 if (expect_false (SvTRUE (ERRSV)))
242 {
243 SPAGAIN;
244 PUSHMARK (SP);
245 PUTBACK;
246 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
247 }
248
249 SP = PL_stack_base + mark;
250 PUTBACK;
251 }
252
253 static void
254 e_once_cb (int revents, void *arg)
255 {
256 dSP;
257 I32 mark = SP - PL_stack_base;
258 SV *sv_events;
259
260 if (sv_events_cache)
261 {
262 sv_events = sv_events_cache; sv_events_cache = 0;
263 SvIV_set (sv_events, revents);
264 }
265 else
266 sv_events = newSViv (revents);
267
268 PUSHMARK (SP);
269 XPUSHs (sv_events);
270
271 PUTBACK;
272 call_sv ((SV *)arg, G_DISCARD | G_VOID | G_EVAL);
273
274 SvREFCNT_dec ((SV *)arg);
275
276 if (sv_events_cache)
277 SvREFCNT_dec (sv_events);
278 else
279 sv_events_cache = sv_events;
280
281 if (SvTRUE (ERRSV))
282 {
283 SPAGAIN;
284 PUSHMARK (SP);
285 PUTBACK;
286 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
287 }
288
289 SP = PL_stack_base + mark;
290 PUTBACK;
291 }
292
293 static ev_tstamp
294 e_periodic_cb (ev_periodic *w, ev_tstamp now)
295 {
296 ev_tstamp retval;
297 int count;
298 dSP;
299
300 ENTER;
301 SAVETMPS;
302
303 PUSHMARK (SP);
304 EXTEND (SP, 2);
305 PUSHs (newRV_inc (e_self (w))); /* e_self (w) MUST be blessed by now */
306 PUSHs (newSVnv (now));
307
308 PUTBACK;
309 count = call_sv (w->fh, G_SCALAR | G_EVAL);
310 SPAGAIN;
311
312 if (SvTRUE (ERRSV))
313 {
314 PUSHMARK (SP);
315 PUTBACK;
316 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
317 SPAGAIN;
318 }
319
320 if (count > 0)
321 {
322 retval = SvNV (TOPs);
323
324 if (retval < now)
325 retval = now;
326 }
327 else
328 retval = now;
329
330 FREETMPS;
331 LEAVE;
332
333 return retval;
334 }
335
336 #define CHECK_REPEAT(repeat) if (repeat < 0.) \
337 croak (# repeat " value must be >= 0");
338
339 #define CHECK_FD(fh,fd) if ((fd) < 0) \
340 croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh));
341
342 #define CHECK_SIG(sv,num) if ((num) < 0) \
343 croak ("illegal signal number or name: %s", SvPV_nolen (sv));
344
345 /////////////////////////////////////////////////////////////////////////////
346 // XS interface functions
347
348 MODULE = EV PACKAGE = EV PREFIX = ev_
349
350 PROTOTYPES: ENABLE
351
352 BOOT:
353 {
354 HV *stash = gv_stashpv ("EV", 1);
355
356 static const struct {
357 const char *name;
358 IV iv;
359 } *civ, const_iv[] = {
360 # define const_iv(pfx, name) { # name, (IV) pfx ## name },
361 const_iv (EV_, MINPRI)
362 const_iv (EV_, MAXPRI)
363
364 const_iv (EV_, UNDEF)
365 const_iv (EV_, NONE)
366 const_iv (EV_, READ)
367 const_iv (EV_, WRITE)
368 const_iv (EV_, IO)
369 const_iv (EV_, TIMEOUT) /* deprecated */
370 const_iv (EV_, TIMER)
371 const_iv (EV_, PERIODIC)
372 const_iv (EV_, SIGNAL)
373 const_iv (EV_, CHILD)
374 const_iv (EV_, STAT)
375 const_iv (EV_, IDLE)
376 const_iv (EV_, PREPARE)
377 const_iv (EV_, CHECK)
378 const_iv (EV_, EMBED)
379 const_iv (EV_, FORK)
380 const_iv (EV_, ASYNC)
381 const_iv (EV_, CUSTOM)
382 const_iv (EV_, ERROR)
383
384 const_iv (EV, LOOP_NONBLOCK)
385 const_iv (EV, LOOP_ONESHOT)
386
387 const_iv (EV, UNLOOP_CANCEL)
388 const_iv (EV, UNLOOP_ONE)
389 const_iv (EV, UNLOOP_ALL)
390
391 const_iv (EV, BACKEND_SELECT)
392 const_iv (EV, BACKEND_POLL)
393 const_iv (EV, BACKEND_EPOLL)
394 const_iv (EV, BACKEND_KQUEUE)
395 const_iv (EV, BACKEND_DEVPOLL)
396 const_iv (EV, BACKEND_PORT)
397 const_iv (EV, BACKEND_ALL)
398 const_iv (EV, FLAG_AUTO)
399 const_iv (EV, FLAG_FORKCHECK)
400 const_iv (EV, FLAG_SIGNALFD)
401 const_iv (EV, FLAG_NOENV)
402 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
403 const_iv (EV, FLAG_NOINOTIFY)
404
405 const_iv (EV_, VERSION_MAJOR)
406 const_iv (EV_, VERSION_MINOR)
407 };
408
409 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
410 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
411
412 stash_loop = gv_stashpv ("EV::Loop" , 1);
413 stash_watcher = gv_stashpv ("EV::Watcher" , 1);
414 stash_io = gv_stashpv ("EV::IO" , 1);
415 stash_timer = gv_stashpv ("EV::Timer" , 1);
416 stash_periodic = gv_stashpv ("EV::Periodic", 1);
417 stash_signal = gv_stashpv ("EV::Signal" , 1);
418 stash_idle = gv_stashpv ("EV::Idle" , 1);
419 stash_prepare = gv_stashpv ("EV::Prepare" , 1);
420 stash_check = gv_stashpv ("EV::Check" , 1);
421 stash_child = gv_stashpv ("EV::Child" , 1);
422 stash_embed = gv_stashpv ("EV::Embed" , 1);
423 stash_stat = gv_stashpv ("EV::Stat" , 1);
424 stash_fork = gv_stashpv ("EV::Fork" , 1);
425 stash_async = gv_stashpv ("EV::Async" , 1);
426
427 {
428 SV *sv = perl_get_sv ("EV::API", TRUE);
429 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
430
431 /* the poor man's shared library emulator */
432 evapi.ver = EV_API_VERSION;
433 evapi.rev = EV_API_REVISION;
434 evapi.sv_fileno = sv_fileno;
435 evapi.sv_signum = s_signum;
436 evapi.supported_backends = ev_supported_backends ();
437 evapi.recommended_backends = ev_recommended_backends ();
438 evapi.embeddable_backends = ev_embeddable_backends ();
439 evapi.time_ = ev_time;
440 evapi.sleep_ = ev_sleep;
441 evapi.loop_new = ev_loop_new;
442 evapi.loop_destroy = ev_loop_destroy;
443 evapi.loop_fork = ev_loop_fork;
444 evapi.iteration = ev_iteration;
445 evapi.depth = ev_depth;
446 evapi.set_userdata = ev_set_userdata;
447 evapi.userdata = ev_userdata;
448 evapi.now = ev_now;
449 evapi.now_update = ev_now_update;
450 evapi.suspend = ev_suspend;
451 evapi.resume = ev_resume;
452 evapi.backend = ev_backend;
453 evapi.unloop = ev_unloop;
454 evapi.invoke_pending = ev_invoke_pending;
455 evapi.pending_count = ev_pending_count;
456 evapi.verify = ev_verify;
457 evapi.set_loop_release_cb = ev_set_loop_release_cb;
458 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb;
459 evapi.ref = ev_ref;
460 evapi.unref = ev_unref;
461 evapi.loop = ev_loop;
462 evapi.once = ev_once;
463 evapi.io_start = ev_io_start;
464 evapi.io_stop = ev_io_stop;
465 evapi.timer_start = ev_timer_start;
466 evapi.timer_stop = ev_timer_stop;
467 evapi.timer_again = ev_timer_again;
468 evapi.timer_remaining = ev_timer_remaining;
469 evapi.periodic_start = ev_periodic_start;
470 evapi.periodic_stop = ev_periodic_stop;
471 evapi.signal_start = ev_signal_start;
472 evapi.signal_stop = ev_signal_stop;
473 evapi.idle_start = ev_idle_start;
474 evapi.idle_stop = ev_idle_stop;
475 evapi.prepare_start = ev_prepare_start;
476 evapi.prepare_stop = ev_prepare_stop;
477 evapi.check_start = ev_check_start;
478 evapi.check_stop = ev_check_stop;
479 evapi.child_start = ev_child_start;
480 evapi.child_stop = ev_child_stop;
481 evapi.stat_start = ev_stat_start;
482 evapi.stat_stop = ev_stat_stop;
483 evapi.stat_stat = ev_stat_stat;
484 evapi.embed_start = ev_embed_start;
485 evapi.embed_stop = ev_embed_stop;
486 evapi.embed_sweep = ev_embed_sweep;
487 evapi.fork_start = ev_fork_start;
488 evapi.fork_stop = ev_fork_stop;
489 evapi.async_start = ev_async_start;
490 evapi.async_stop = ev_async_stop;
491 evapi.async_send = ev_async_send;
492 evapi.clear_pending = ev_clear_pending;
493 evapi.invoke = ev_invoke;
494
495 sv_setiv (sv, (IV)&evapi);
496 SvREADONLY_on (sv);
497 }
498 #ifndef _WIN32
499 pthread_atfork (0, 0, ev_default_fork);
500 #endif
501 }
502
503 SV *ev_default_loop (unsigned int flags = 0)
504 CODE:
505 {
506 if (!default_loop_sv)
507 {
508 evapi.default_loop = ev_default_loop (flags);
509
510 if (!evapi.default_loop)
511 XSRETURN_UNDEF;
512
513 default_loop_sv = sv_bless (newRV_noinc (newSViv (PTR2IV (evapi.default_loop))), stash_loop);
514 }
515
516 RETVAL = newSVsv (default_loop_sv);
517 }
518 OUTPUT:
519 RETVAL
520
521 void ev_default_destroy ()
522 CODE:
523 ev_default_destroy ();
524 SvREFCNT_dec (default_loop_sv);
525 default_loop_sv = 0;
526
527 unsigned int ev_supported_backends ()
528
529 unsigned int ev_recommended_backends ()
530
531 unsigned int ev_embeddable_backends ()
532
533 void ev_sleep (NV interval)
534
535 NV ev_time ()
536
537 NV ev_now ()
538 C_ARGS: evapi.default_loop
539
540 void ev_now_update ()
541 C_ARGS: evapi.default_loop
542
543 void ev_suspend ()
544 C_ARGS: evapi.default_loop
545
546 void ev_resume ()
547 C_ARGS: evapi.default_loop
548
549 unsigned int ev_backend ()
550 C_ARGS: evapi.default_loop
551
552 void ev_verify ()
553 C_ARGS: evapi.default_loop
554
555 unsigned int ev_iteration ()
556 C_ARGS: evapi.default_loop
557
558 unsigned int ev_depth ()
559 C_ARGS: evapi.default_loop
560
561 void ev_set_io_collect_interval (NV interval)
562 C_ARGS: evapi.default_loop, interval
563
564 void ev_set_timeout_collect_interval (NV interval)
565 C_ARGS: evapi.default_loop, interval
566
567 void ev_loop (int flags = 0)
568 C_ARGS: evapi.default_loop, flags
569
570 void ev_unloop (int how = EVUNLOOP_ONE)
571 C_ARGS: evapi.default_loop, how
572
573 void ev_feed_fd_event (int fd, int revents = EV_NONE)
574 C_ARGS: evapi.default_loop, fd, revents
575
576 void ev_feed_signal_event (SV *signal)
577 CODE:
578 {
579 Signal signum = s_signum (signal);
580 CHECK_SIG (signal, signum);
581
582 ev_feed_signal_event (evapi.default_loop, signum);
583 }
584
585 unsigned int ev_pending_count ()
586 C_ARGS: evapi.default_loop
587
588 void ev_invoke_pending ()
589 C_ARGS: evapi.default_loop
590
591 ev_io *io (SV *fh, int events, SV *cb)
592 ALIAS:
593 io_ns = 1
594 _ae_io = 2
595 CODE:
596 {
597 int fd = s_fileno (fh, events & EV_WRITE);
598 CHECK_FD (fh, fd);
599
600 if (ix == 2)
601 {
602 ix = 0;
603 events = events ? EV_WRITE : EV_READ;
604 }
605
606 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv);
607 e_fh (RETVAL) = newSVsv (fh);
608 ev_io_set (RETVAL, fd, events);
609 if (!ix) START (io, RETVAL);
610 }
611 OUTPUT:
612 RETVAL
613
614 ev_timer *timer (NV after, NV repeat, SV *cb)
615 ALIAS:
616 timer_ns = 1
617 INIT:
618 CHECK_REPEAT (repeat);
619 CODE:
620 RETVAL = e_new (sizeof (ev_timer), cb, default_loop_sv);
621 ev_timer_set (RETVAL, after, repeat);
622 if (!ix) START (timer, RETVAL);
623 OUTPUT:
624 RETVAL
625
626 SV *periodic (NV at, NV interval, SV *reschedule_cb, SV *cb)
627 ALIAS:
628 periodic_ns = 1
629 INIT:
630 CHECK_REPEAT (interval);
631 CODE:
632 {
633 ev_periodic *w;
634 w = e_new (sizeof (ev_periodic), cb, default_loop_sv);
635 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
636 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
637 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
638 if (!ix) START (periodic, w);
639 }
640 OUTPUT:
641 RETVAL
642
643 ev_signal *signal (SV *signal, SV *cb)
644 ALIAS:
645 signal_ns = 1
646 CODE:
647 {
648 Signal signum = s_signum (signal);
649 CHECK_SIG (signal, signum);
650
651 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv);
652 ev_signal_set (RETVAL, signum);
653 if (!ix) START_SIGNAL (RETVAL);
654 }
655 OUTPUT:
656 RETVAL
657
658 ev_idle *idle (SV *cb)
659 ALIAS:
660 idle_ns = 1
661 CODE:
662 RETVAL = e_new (sizeof (ev_idle), cb, default_loop_sv);
663 ev_idle_set (RETVAL);
664 if (!ix) START (idle, RETVAL);
665 OUTPUT:
666 RETVAL
667
668 ev_prepare *prepare (SV *cb)
669 ALIAS:
670 prepare_ns = 1
671 CODE:
672 RETVAL = e_new (sizeof (ev_prepare), cb, default_loop_sv);
673 ev_prepare_set (RETVAL);
674 if (!ix) START (prepare, RETVAL);
675 OUTPUT:
676 RETVAL
677
678 ev_check *check (SV *cb)
679 ALIAS:
680 check_ns = 1
681 CODE:
682 RETVAL = e_new (sizeof (ev_check), cb, default_loop_sv);
683 ev_check_set (RETVAL);
684 if (!ix) START (check, RETVAL);
685 OUTPUT:
686 RETVAL
687
688 ev_fork *fork (SV *cb)
689 ALIAS:
690 fork_ns = 1
691 CODE:
692 RETVAL = e_new (sizeof (ev_fork), cb, default_loop_sv);
693 ev_fork_set (RETVAL);
694 if (!ix) START (fork, RETVAL);
695 OUTPUT:
696 RETVAL
697
698 ev_child *child (int pid, int trace, SV *cb)
699 ALIAS:
700 child_ns = 1
701 CODE:
702 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv);
703 ev_child_set (RETVAL, pid, trace);
704 if (!ix) START (child, RETVAL);
705 OUTPUT:
706 RETVAL
707
708 ev_stat *stat (SV *path, NV interval, SV *cb)
709 ALIAS:
710 stat_ns = 1
711 CODE:
712 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv);
713 e_fh (RETVAL) = newSVsv (path);
714 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
715 if (!ix) START (stat, RETVAL);
716 OUTPUT:
717 RETVAL
718
719 ev_embed *embed (struct ev_loop *loop, SV *cb = 0)
720 ALIAS:
721 embed_ns = 1
722 CODE:
723 {
724 if (!(ev_backend (loop) & ev_embeddable_backends ()))
725 croak ("passed loop is not embeddable via EV::embed,");
726
727 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv);
728 e_fh (RETVAL) = newSVsv (ST (0));
729 ev_embed_set (RETVAL, loop);
730 if (!ix) START (embed, RETVAL);
731 }
732 OUTPUT:
733 RETVAL
734
735 ev_async *async (SV *cb)
736 ALIAS:
737 async_ns = 1
738 CODE:
739 RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv);
740 ev_async_set (RETVAL);
741 if (!ix) START (async, RETVAL);
742 OUTPUT:
743 RETVAL
744
745 void once (SV *fh, int events, SV *timeout, SV *cb)
746 CODE:
747 ev_once (
748 evapi.default_loop,
749 s_fileno (fh, events & EV_WRITE), events,
750 SvOK (timeout) ? SvNV (timeout) : -1.,
751 e_once_cb,
752 newSVsv (cb)
753 );
754
755 PROTOTYPES: DISABLE
756
757 MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_
758
759 int ev_is_active (ev_watcher *w)
760
761 int ev_is_pending (ev_watcher *w)
762
763 void ev_invoke (ev_watcher *w, int revents = EV_NONE)
764 C_ARGS: e_loop (w), w, revents
765
766 int ev_clear_pending (ev_watcher *w)
767 C_ARGS: e_loop (w), w
768
769 void ev_feed_event (ev_watcher *w, int revents = EV_NONE)
770 C_ARGS: e_loop (w), w, revents
771
772 int keepalive (ev_watcher *w, int new_value = 0)
773 CODE:
774 {
775 RETVAL = w->e_flags & WFLAG_KEEPALIVE;
776 new_value = new_value ? WFLAG_KEEPALIVE : 0;
777
778 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE))
779 {
780 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value;
781 REF (w);
782 UNREF (w);
783 }
784 }
785 OUTPUT:
786 RETVAL
787
788 SV *cb (ev_watcher *w, SV *new_cb = 0)
789 CODE:
790 {
791 if (items > 1)
792 {
793 new_cb = s_get_cv_croak (new_cb);
794 RETVAL = newRV_noinc (w->cb_sv);
795 w->cb_sv = SvREFCNT_inc (new_cb);
796 }
797 else
798 RETVAL = newRV_inc (w->cb_sv);
799 }
800 OUTPUT:
801 RETVAL
802
803 SV *data (ev_watcher *w, SV *new_data = 0)
804 CODE:
805 {
806 RETVAL = w->data ? newSVsv (w->data) : &PL_sv_undef;
807
808 if (items > 1)
809 {
810 SvREFCNT_dec (w->data);
811 w->data = newSVsv (new_data);
812 }
813 }
814 OUTPUT:
815 RETVAL
816
817 SV *loop (ev_watcher *w)
818 CODE:
819 RETVAL = newRV_inc (w->loop);
820 OUTPUT:
821 RETVAL
822
823 int priority (ev_watcher *w, int new_priority = 0)
824 CODE:
825 {
826 RETVAL = w->priority;
827
828 if (items > 1)
829 {
830 int active = ev_is_active (w);
831
832 if (active)
833 {
834 /* grrr. */
835 PUSHMARK (SP);
836 XPUSHs (ST (0));
837 PUTBACK;
838 call_method ("stop", G_DISCARD | G_VOID);
839 }
840
841 ev_set_priority (w, new_priority);
842
843 if (active)
844 {
845 PUSHMARK (SP);
846 XPUSHs (ST (0));
847 PUTBACK;
848 call_method ("start", G_DISCARD | G_VOID);
849 }
850 }
851 }
852 OUTPUT:
853 RETVAL
854
855 MODULE = EV PACKAGE = EV::IO PREFIX = ev_io_
856
857 void ev_io_start (ev_io *w)
858 CODE:
859 START (io, w);
860
861 void ev_io_stop (ev_io *w)
862 CODE:
863 STOP (io, w);
864
865 void DESTROY (ev_io *w)
866 CODE:
867 STOP (io, w);
868 e_destroy (w);
869
870 void set (ev_io *w, SV *fh, int events)
871 CODE:
872 {
873 int fd = s_fileno (fh, events & EV_WRITE);
874 CHECK_FD (fh, fd);
875
876 sv_setsv (e_fh (w), fh);
877 RESET (io, w, (w, fd, events));
878 }
879
880 SV *fh (ev_io *w, SV *new_fh = 0)
881 CODE:
882 {
883 if (items > 1)
884 {
885 int fd = s_fileno (new_fh, w->events & EV_WRITE);
886 CHECK_FD (new_fh, fd);
887
888 RETVAL = e_fh (w);
889 e_fh (w) = newSVsv (new_fh);
890
891 RESET (io, w, (w, fd, w->events));
892 }
893 else
894 RETVAL = newSVsv (e_fh (w));
895 }
896 OUTPUT:
897 RETVAL
898
899 int events (ev_io *w, int new_events = EV_UNDEF)
900 CODE:
901 {
902 RETVAL = w->events;
903
904 if (items > 1)
905 RESET (io, w, (w, w->fd, new_events));
906 }
907 OUTPUT:
908 RETVAL
909
910 MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_
911
912 void ev_signal_start (ev_signal *w)
913 CODE:
914 START_SIGNAL (w);
915
916 void ev_signal_stop (ev_signal *w)
917 CODE:
918 STOP (signal, w);
919
920 void DESTROY (ev_signal *w)
921 CODE:
922 STOP (signal, w);
923 e_destroy (w);
924
925 void set (ev_signal *w, SV *signal)
926 CODE:
927 {
928 Signal signum = s_signum (signal);
929 CHECK_SIG (signal, signum);
930
931 RESET_SIGNAL (w, (w, signum));
932 }
933
934 int signal (ev_signal *w, SV *new_signal = 0)
935 CODE:
936 {
937 RETVAL = w->signum;
938
939 if (items > 1)
940 {
941 Signal signum = s_signum (new_signal);
942 CHECK_SIG (new_signal, signum);
943
944 RESET_SIGNAL (w, (w, signum));
945 }
946 }
947 OUTPUT:
948 RETVAL
949
950 MODULE = EV PACKAGE = EV::Timer PREFIX = ev_timer_
951
952 void ev_timer_start (ev_timer *w)
953 INIT:
954 CHECK_REPEAT (w->repeat);
955 CODE:
956 START (timer, w);
957
958 void ev_timer_stop (ev_timer *w)
959 CODE:
960 STOP (timer, w);
961
962 void ev_timer_again (ev_timer *w)
963 INIT:
964 CHECK_REPEAT (w->repeat);
965 CODE:
966 ev_timer_again (e_loop (w), w);
967 UNREF (w);
968
969 NV ev_timer_remaining (ev_timer *w)
970 C_ARGS: e_loop (w), w
971
972 void DESTROY (ev_timer *w)
973 CODE:
974 STOP (timer, w);
975 e_destroy (w);
976
977 void set (ev_timer *w, NV after, NV repeat = 0.)
978 INIT:
979 CHECK_REPEAT (repeat);
980 CODE:
981 RESET (timer, w, (w, after, repeat));
982
983 MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
984
985 void ev_periodic_start (ev_periodic *w)
986 INIT:
987 CHECK_REPEAT (w->interval);
988 CODE:
989 START (periodic, w);
990
991 void ev_periodic_stop (ev_periodic *w)
992 CODE:
993 STOP (periodic, w);
994
995 void ev_periodic_again (ev_periodic *w)
996 CODE:
997 ev_periodic_again (e_loop (w), w);
998 UNREF (w);
999
1000 void DESTROY (ev_periodic *w)
1001 CODE:
1002 STOP (periodic, w);
1003 e_destroy (w);
1004
1005 void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef)
1006 INIT:
1007 CHECK_REPEAT (interval);
1008 CODE:
1009 {
1010 SvREFCNT_dec (e_fh (w));
1011 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1012
1013 RESET (periodic, w, (w, at, interval, e_fh (w) ? e_periodic_cb : 0));
1014 }
1015
1016 NV at (ev_periodic *w)
1017 CODE:
1018 RETVAL = ev_periodic_at (w);
1019 OUTPUT:
1020 RETVAL
1021
1022 MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
1023
1024 void ev_idle_start (ev_idle *w)
1025 CODE:
1026 START (idle, w);
1027
1028 void ev_idle_stop (ev_idle *w)
1029 CODE:
1030 STOP (idle, w);
1031
1032 void DESTROY (ev_idle *w)
1033 CODE:
1034 STOP (idle, w);
1035 e_destroy (w);
1036
1037 MODULE = EV PACKAGE = EV::Prepare PREFIX = ev_prepare_
1038
1039 void ev_prepare_start (ev_prepare *w)
1040 CODE:
1041 START (prepare, w);
1042
1043 void ev_prepare_stop (ev_prepare *w)
1044 CODE:
1045 STOP (prepare, w);
1046
1047 void DESTROY (ev_prepare *w)
1048 CODE:
1049 STOP (prepare, w);
1050 e_destroy (w);
1051
1052 MODULE = EV PACKAGE = EV::Check PREFIX = ev_check_
1053
1054 void ev_check_start (ev_check *w)
1055 CODE:
1056 START (check, w);
1057
1058 void ev_check_stop (ev_check *w)
1059 CODE:
1060 STOP (check, w);
1061
1062 void DESTROY (ev_check *w)
1063 CODE:
1064 STOP (check, w);
1065 e_destroy (w);
1066
1067 MODULE = EV PACKAGE = EV::Fork PREFIX = ev_fork_
1068
1069 void ev_fork_start (ev_fork *w)
1070 CODE:
1071 START (fork, w);
1072
1073 void ev_fork_stop (ev_fork *w)
1074 CODE:
1075 STOP (fork, w);
1076
1077 void DESTROY (ev_fork *w)
1078 CODE:
1079 STOP (fork, w);
1080 e_destroy (w);
1081
1082 MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
1083
1084 void ev_child_start (ev_child *w)
1085 CODE:
1086 START (child, w);
1087
1088 void ev_child_stop (ev_child *w)
1089 CODE:
1090 STOP (child, w);
1091
1092 void DESTROY (ev_child *w)
1093 CODE:
1094 STOP (child, w);
1095 e_destroy (w);
1096
1097 void set (ev_child *w, int pid, int trace)
1098 CODE:
1099 RESET (child, w, (w, pid, trace));
1100
1101 int pid (ev_child *w)
1102 ALIAS:
1103 rpid = 1
1104 rstatus = 2
1105 CODE:
1106 RETVAL = ix == 0 ? w->pid
1107 : ix == 1 ? w->rpid
1108 : w->rstatus;
1109 OUTPUT:
1110 RETVAL
1111
1112 MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_
1113
1114 void ev_stat_start (ev_stat *w)
1115 CODE:
1116 START (stat, w);
1117
1118 void ev_stat_stop (ev_stat *w)
1119 CODE:
1120 STOP (stat, w);
1121
1122 void DESTROY (ev_stat *w)
1123 CODE:
1124 STOP (stat, w);
1125 e_destroy (w);
1126
1127 void set (ev_stat *w, SV *path, NV interval)
1128 CODE:
1129 {
1130 sv_setsv (e_fh (w), path);
1131 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1132 }
1133
1134 SV *path (ev_stat *w, SV *new_path = 0)
1135 CODE:
1136 {
1137 RETVAL = SvREFCNT_inc (e_fh (w));
1138
1139 if (items > 1)
1140 {
1141 SvREFCNT_dec (e_fh (w));
1142 e_fh (w) = newSVsv (new_path);
1143 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1144 }
1145 }
1146 OUTPUT:
1147 RETVAL
1148
1149 NV interval (ev_stat *w, NV new_interval = 0.)
1150 CODE:
1151 {
1152 RETVAL = w->interval;
1153
1154 if (items > 1)
1155 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval));
1156 }
1157 OUTPUT:
1158 RETVAL
1159
1160 void prev (ev_stat *w)
1161 ALIAS:
1162 stat = 1
1163 attr = 2
1164 PPCODE:
1165 {
1166 ev_statdata *s = ix ? &w->attr : &w->prev;
1167
1168 if (ix == 1)
1169 ev_stat_stat (e_loop (w), w);
1170 else if (!s->st_nlink)
1171 errno = ENOENT;
1172
1173 PL_statcache.st_dev = s->st_nlink;
1174 PL_statcache.st_ino = s->st_ino;
1175 PL_statcache.st_mode = s->st_mode;
1176 PL_statcache.st_nlink = s->st_nlink;
1177 PL_statcache.st_uid = s->st_uid;
1178 PL_statcache.st_gid = s->st_gid;
1179 PL_statcache.st_rdev = s->st_rdev;
1180 PL_statcache.st_size = s->st_size;
1181 PL_statcache.st_atime = s->st_atime;
1182 PL_statcache.st_mtime = s->st_mtime;
1183 PL_statcache.st_ctime = s->st_ctime;
1184
1185 if (GIMME_V == G_SCALAR)
1186 XPUSHs (boolSV (s->st_nlink));
1187 else if (GIMME_V == G_ARRAY && s->st_nlink)
1188 {
1189 EXTEND (SP, 13);
1190 PUSHs (sv_2mortal (newSViv (s->st_dev)));
1191 PUSHs (sv_2mortal (newSViv (s->st_ino)));
1192 PUSHs (sv_2mortal (newSVuv (s->st_mode)));
1193 PUSHs (sv_2mortal (newSVuv (s->st_nlink)));
1194 PUSHs (sv_2mortal (newSViv (s->st_uid)));
1195 PUSHs (sv_2mortal (newSViv (s->st_gid)));
1196 PUSHs (sv_2mortal (newSViv (s->st_rdev)));
1197 PUSHs (sv_2mortal (newSVnv ((NV)s->st_size)));
1198 PUSHs (sv_2mortal (newSVnv (s->st_atime)));
1199 PUSHs (sv_2mortal (newSVnv (s->st_mtime)));
1200 PUSHs (sv_2mortal (newSVnv (s->st_ctime)));
1201 PUSHs (sv_2mortal (newSVuv (4096)));
1202 PUSHs (sv_2mortal (newSVnv ((NV)((s->st_size + 4095) / 4096))));
1203 }
1204 }
1205
1206 MODULE = EV PACKAGE = EV::Embed PREFIX = ev_embed_
1207
1208 void ev_embed_start (ev_embed *w)
1209 CODE:
1210 START (embed, w);
1211
1212 void ev_embed_stop (ev_embed *w)
1213 CODE:
1214 STOP (embed, w);
1215
1216 void DESTROY (ev_embed *w)
1217 CODE:
1218 STOP (embed, w);
1219 e_destroy (w);
1220
1221 void set (ev_embed *w, struct ev_loop *loop)
1222 CODE:
1223 {
1224 sv_setsv (e_fh (w), ST (1));
1225 RESET (embed, w, (w, loop));
1226 }
1227
1228 SV *other (ev_embed *w)
1229 CODE:
1230 RETVAL = newSVsv (e_fh (w));
1231 OUTPUT:
1232 RETVAL
1233
1234 void ev_embed_sweep (ev_embed *w)
1235 C_ARGS: e_loop (w), w
1236
1237 MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_
1238
1239 void ev_async_start (ev_async *w)
1240 CODE:
1241 START (async, w);
1242
1243 void ev_async_stop (ev_async *w)
1244 CODE:
1245 STOP (async, w);
1246
1247 void DESTROY (ev_async *w)
1248 CODE:
1249 STOP (async, w);
1250 e_destroy (w);
1251
1252 void ev_async_send (ev_async *w)
1253 C_ARGS: e_loop (w), w
1254
1255 SV *ev_async_async_pending (ev_async *w)
1256 CODE:
1257 RETVAL = boolSV (ev_async_pending (w));
1258 OUTPUT:
1259 RETVAL
1260
1261 MODULE = EV PACKAGE = EV::Loop PREFIX = ev_
1262
1263 SV *new (SV *klass, unsigned int flags = 0)
1264 CODE:
1265 {
1266 struct ev_loop *loop = ev_loop_new (flags);
1267
1268 if (!loop)
1269 XSRETURN_UNDEF;
1270
1271 RETVAL = sv_bless (newRV_noinc (newSViv (PTR2IV (loop))), stash_loop);
1272 }
1273 OUTPUT:
1274 RETVAL
1275
1276 void DESTROY (struct ev_loop *loop)
1277 CODE:
1278 if (loop != evapi.default_loop) /* global destruction sucks */
1279 ev_loop_destroy (loop);
1280
1281 void ev_loop_fork (struct ev_loop *loop)
1282
1283 void ev_verify (struct ev_loop *loop)
1284
1285 NV ev_now (struct ev_loop *loop)
1286
1287 void ev_now_update (struct ev_loop *loop)
1288
1289 void ev_suspend (struct ev_loop *loop)
1290
1291 void ev_resume (struct ev_loop *loop)
1292
1293 void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1294
1295 void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1296
1297 unsigned int ev_backend (struct ev_loop *loop)
1298
1299 unsigned int ev_iteration (struct ev_loop *loop)
1300
1301 unsigned int ev_depth (struct ev_loop *loop)
1302
1303 void ev_loop (struct ev_loop *loop, int flags = 0)
1304
1305 void ev_unloop (struct ev_loop *loop, int how = 1)
1306
1307 void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1308
1309 unsigned int ev_pending_count (struct ev_loop *loop)
1310
1311 void ev_invoke_pending (struct ev_loop *loop)
1312
1313 #if 0
1314
1315 void ev_feed_signal_event (struct ev_loop *loop, SV *signal)
1316 CODE:
1317 {
1318 Signal signum = s_signum (signal);
1319 CHECK_SIG (signal, signum);
1320
1321 ev_feed_signal_event (loop, signum);
1322 }
1323
1324 #endif
1325
1326 ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb)
1327 ALIAS:
1328 io_ns = 1
1329 CODE:
1330 {
1331 int fd = s_fileno (fh, events & EV_WRITE);
1332 CHECK_FD (fh, fd);
1333
1334 RETVAL = e_new (sizeof (ev_io), cb, ST (0));
1335 e_fh (RETVAL) = newSVsv (fh);
1336 ev_io_set (RETVAL, fd, events);
1337 if (!ix) START (io, RETVAL);
1338 }
1339 OUTPUT:
1340 RETVAL
1341
1342 ev_timer *timer (struct ev_loop *loop, NV after, NV repeat, SV *cb)
1343 ALIAS:
1344 timer_ns = 1
1345 INIT:
1346 CHECK_REPEAT (repeat);
1347 CODE:
1348 RETVAL = e_new (sizeof (ev_timer), cb, ST (0));
1349 ev_timer_set (RETVAL, after, repeat);
1350 if (!ix) START (timer, RETVAL);
1351 OUTPUT:
1352 RETVAL
1353
1354 SV *periodic (struct ev_loop *loop, NV at, NV interval, SV *reschedule_cb, SV *cb)
1355 ALIAS:
1356 periodic_ns = 1
1357 INIT:
1358 CHECK_REPEAT (interval);
1359 CODE:
1360 {
1361 ev_periodic *w;
1362 w = e_new (sizeof (ev_periodic), cb, ST (0));
1363 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1364 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
1365 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1366 if (!ix) START (periodic, w);
1367 }
1368 OUTPUT:
1369 RETVAL
1370
1371 ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb)
1372 ALIAS:
1373 signal_ns = 1
1374 CODE:
1375 {
1376 Signal signum = s_signum (signal);
1377 CHECK_SIG (signal, signum);
1378
1379 RETVAL = e_new (sizeof (ev_signal), cb, ST (0));
1380 ev_signal_set (RETVAL, signum);
1381 if (!ix) START_SIGNAL (RETVAL);
1382 }
1383 OUTPUT:
1384 RETVAL
1385
1386 ev_idle *idle (struct ev_loop *loop, SV *cb)
1387 ALIAS:
1388 idle_ns = 1
1389 CODE:
1390 RETVAL = e_new (sizeof (ev_idle), cb, ST (0));
1391 ev_idle_set (RETVAL);
1392 if (!ix) START (idle, RETVAL);
1393 OUTPUT:
1394 RETVAL
1395
1396 ev_prepare *prepare (struct ev_loop *loop, SV *cb)
1397 ALIAS:
1398 prepare_ns = 1
1399 CODE:
1400 RETVAL = e_new (sizeof (ev_prepare), cb, ST (0));
1401 ev_prepare_set (RETVAL);
1402 if (!ix) START (prepare, RETVAL);
1403 OUTPUT:
1404 RETVAL
1405
1406 ev_check *check (struct ev_loop *loop, SV *cb)
1407 ALIAS:
1408 check_ns = 1
1409 CODE:
1410 RETVAL = e_new (sizeof (ev_check), cb, ST (0));
1411 ev_check_set (RETVAL);
1412 if (!ix) START (check, RETVAL);
1413 OUTPUT:
1414 RETVAL
1415
1416 ev_fork *fork (struct ev_loop *loop, SV *cb)
1417 ALIAS:
1418 fork_ns = 1
1419 CODE:
1420 RETVAL = e_new (sizeof (ev_fork), cb, ST (0));
1421 ev_fork_set (RETVAL);
1422 if (!ix) START (fork, RETVAL);
1423 OUTPUT:
1424 RETVAL
1425
1426 ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1427 ALIAS:
1428 child_ns = 1
1429 CODE:
1430 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1431 ev_child_set (RETVAL, pid, trace);
1432 if (!ix) START (child, RETVAL);
1433 OUTPUT:
1434 RETVAL
1435
1436 ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1437 ALIAS:
1438 stat_ns = 1
1439 CODE:
1440 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1441 e_fh (RETVAL) = newSVsv (path);
1442 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
1443 if (!ix) START (stat, RETVAL);
1444 OUTPUT:
1445 RETVAL
1446
1447 ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0)
1448 ALIAS:
1449 embed_ns = 1
1450 CODE:
1451 {
1452 if (!(ev_backend (other) & ev_embeddable_backends ()))
1453 croak ("passed loop is not embeddable via EV::embed,");
1454
1455 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1456 e_fh (RETVAL) = newSVsv (ST (1));
1457 ev_embed_set (RETVAL, other);
1458 if (!ix) START (embed, RETVAL);
1459 }
1460 OUTPUT:
1461 RETVAL
1462
1463 ev_async *async (struct ev_loop *loop, SV *cb)
1464 ALIAS:
1465 async_ns = 1
1466 CODE:
1467 RETVAL = e_new (sizeof (ev_async), cb, ST (0));
1468 ev_async_set (RETVAL);
1469 if (!ix) START (async, RETVAL);
1470 OUTPUT:
1471 RETVAL
1472
1473 void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1474 CODE:
1475 ev_once (
1476 loop,
1477 s_fileno (fh, events & EV_WRITE), events,
1478 SvOK (timeout) ? SvNV (timeout) : -1.,
1479 e_once_cb,
1480 newSVsv (cb)
1481 );
1482