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

Comparing EV/EV.xs (file contents):
Revision 1.105 by root, Thu Jan 31 20:10:28 2008 UTC vs.
Revision 1.124 by root, Mon Jun 29 18:46:52 2009 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
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
7/* fix perl api breakage */
8#undef signal
9#undef sigaction
6 10
7#define EV_PROTOTYPES 1 11#define EV_PROTOTYPES 1
8#define EV_USE_NANOSLEEP EV_USE_MONOTONIC 12#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
9#define EV_H <ev.h> 13#define EV_H <ev.h>
10#include "EV/EVAPI.h" 14#include "EV/EVAPI.h"
11
12/* fix perl api breakage */
13#undef signal
14#undef sigaction
15 15
16#define EV_SELECT_IS_WINSOCKET 0 16#define EV_SELECT_IS_WINSOCKET 0
17#ifdef _WIN32 17#ifdef _WIN32
18# define EV_SELECT_USE_FD_SET 0 18# define EV_SELECT_USE_FD_SET 0
19# define NFDBITS PERL_NFDBITS 19# define NFDBITS PERL_NFDBITS
24 24
25#ifndef _WIN32 25#ifndef _WIN32
26# include <pthread.h> 26# include <pthread.h>
27#endif 27#endif
28 28
29/* 5.10.0 */
30#ifndef SvREFCNT_inc_NN
31# define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv)
32#endif
33
34/* 5.6.x */
35#ifndef SvRV_set
36# define SvRV_set(a,b) SvRV ((a)) = (b)
37#endif
38
29#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) 39#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop))
30 40
31#define WFLAG_KEEPALIVE 1 41#define WFLAG_KEEPALIVE 1
42#define WFLAG_UNREFED 2 /* has been unref'ed */
32 43
33#define UNREF(w) \ 44#define UNREF(w) \
34 if (!((w)->e_flags & WFLAG_KEEPALIVE) \ 45 if (!((w)->e_flags & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \
35 && !ev_is_active (w)) \ 46 && ev_is_active (w)) \
47 { \
36 ev_unref (e_loop (w)); 48 ev_unref (e_loop (w)); \
49 (w)->e_flags |= WFLAG_UNREFED; \
50 }
37 51
38#define REF(w) \ 52#define REF(w) \
39 if (!((w)->e_flags & WFLAG_KEEPALIVE) \ 53 if ((w)->e_flags & WFLAG_UNREFED) \
40 && ev_is_active (w)) \ 54 { \
55 (w)->e_flags &= ~WFLAG_UNREFED; \
41 ev_ref (e_loop (w)); 56 ev_ref (e_loop (w)); \
57 }
42 58
43#define START(type,w) \ 59#define START(type,w) \
44 do { \ 60 do { \
61 ev_ ## type ## _start (e_loop (w), w); \
45 UNREF (w); \ 62 UNREF (w); \
46 ev_ ## type ## _start (e_loop (w), w); \
47 } while (0) 63 } while (0)
48 64
49#define STOP(type,w) \ 65#define STOP(type,w) \
50 do { \ 66 do { \
51 REF (w); \ 67 REF (w); \
77 *stash_stat, 93 *stash_stat,
78 *stash_idle, 94 *stash_idle,
79 *stash_prepare, 95 *stash_prepare,
80 *stash_check, 96 *stash_check,
81 *stash_embed, 97 *stash_embed,
82 *stash_fork; 98 *stash_fork,
99 *stash_async;
83 100
84#ifndef SIG_SIZE 101#ifndef SIG_SIZE
85/* kudos to Slaven Rezic for the idea */ 102/* kudos to Slaven Rezic for the idea */
86static char sig_size [] = { SIG_NUM }; 103static char sig_size [] = { SIG_NUM };
87# define SIG_SIZE (sizeof (sig_size) + 1) 104# define SIG_SIZE (sizeof (sig_size) + 1)
126 return SvIV (fh); 143 return SvIV (fh);
127 144
128 return -1; 145 return -1;
129} 146}
130 147
148static SV *
149e_get_cv (SV *cb_sv)
150{
151 HV *st;
152 GV *gvp;
153 CV *cv = sv_2cv (cb_sv, &st, &gvp, 0);
154
155 if (!cv)
156 croak ("EV watcher callback must be a CODE reference");
157
158 return (SV *)cv;
159}
160
131static void * 161static void *
132e_new (int size, SV *cb_sv, SV *loop) 162e_new (int size, SV *cb_sv, SV *loop)
133{ 163{
164 SV *cv = cb_sv ? e_get_cv (cb_sv) : 0;
134 ev_watcher *w; 165 ev_watcher *w;
135 SV *self = NEWSV (0, size); 166 SV *self = NEWSV (0, size);
136 SvPOK_only (self); 167 SvPOK_only (self);
137 SvCUR_set (self, size); 168 SvCUR_set (self, size);
138 169
139 w = (ev_watcher *)SvPVX (self); 170 w = (ev_watcher *)SvPVX (self);
140 171
141 ev_init (w, e_cb); 172 ev_init (w, cv ? e_cb : 0);
142 173
143 w->loop = SvREFCNT_inc (SvRV (loop)); 174 w->loop = SvREFCNT_inc (SvRV (loop));
144 w->e_flags = WFLAG_KEEPALIVE; 175 w->e_flags = WFLAG_KEEPALIVE;
145 w->data = 0; 176 w->data = 0;
146 w->fh = 0; 177 w->fh = 0;
147 w->cb_sv = SvTEMP (cb_sv) && SvREFCNT (cb_sv) == 1 ? SvREFCNT_inc (cb_sv) : newSVsv (cb_sv); 178 w->cb_sv = SvREFCNT_inc (cv);
148 w->self = self; 179 w->self = self;
149 180
150 return (void *)w; 181 return (void *)w;
151} 182}
152 183
176 } 207 }
177 208
178 return rv; 209 return rv;
179} 210}
180 211
181static SV *sv_events_cache; 212static SV *sv_self_cache, *sv_events_cache;
182 213
183static void 214static void
184e_cb (EV_P_ ev_watcher *w, int revents) 215e_cb (EV_P_ ev_watcher *w, int revents)
185{ 216{
186 dSP; 217 dSP;
187 I32 mark = SP - PL_stack_base; 218 I32 mark = SP - PL_stack_base;
188 SV *sv_self, *sv_events; 219 SV *sv_self, *sv_events;
189 220
221 /* libev might have stopped the watcher */
222 if (expect_false (w->e_flags & WFLAG_UNREFED)
223 && !ev_is_active (w))
224 REF (w);
225
226 if (expect_true (sv_self_cache))
227 {
228 sv_self = sv_self_cache; sv_self_cache = 0;
229 SvRV_set (sv_self, SvREFCNT_inc_NN (w->self));
230 }
231 else
232 {
190 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ 233 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */
234 SvREADONLY_on (sv_self);
235 }
236
237 if (expect_true (sv_events_cache))
238 {
239 sv_events = sv_events_cache; sv_events_cache = 0;
240 SvIV_set (sv_events, revents);
241 }
242 else
243 {
244 sv_events = newSViv (revents);
245 SvREADONLY_on (sv_events);
246 }
247
248 PUSHMARK (SP);
249 EXTEND (SP, 2);
250 PUSHs (sv_self);
251 PUSHs (sv_events);
252
253 PUTBACK;
254 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
255
256 if (expect_false (SvREFCNT (sv_self) != 1 || sv_self_cache))
257 SvREFCNT_dec (sv_self);
258 else
259 {
260 SvREFCNT_dec (SvRV (sv_self));
261 SvRV_set (sv_self, &PL_sv_undef);
262 sv_self_cache = sv_self;
263 }
264
265 if (expect_false (SvREFCNT (sv_events) != 1 || sv_events_cache))
266 SvREFCNT_dec (sv_events);
267 else
268 sv_events_cache = sv_events;
269
270 if (expect_false (SvTRUE (ERRSV)))
271 {
272 SPAGAIN;
273 PUSHMARK (SP);
274 PUTBACK;
275 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
276 }
277
278 SP = PL_stack_base + mark;
279 PUTBACK;
280}
281
282static void
283e_once_cb (int revents, void *arg)
284{
285 dSP;
286 I32 mark = SP - PL_stack_base;
287 SV *sv_events;
191 288
192 if (sv_events_cache) 289 if (sv_events_cache)
193 { 290 {
194 sv_events = sv_events_cache; sv_events_cache = 0; 291 sv_events = sv_events_cache; sv_events_cache = 0;
195 SvIV_set (sv_events, revents); 292 SvIV_set (sv_events, revents);
196 } 293 }
197 else 294 else
198 sv_events = newSViv (revents); 295 sv_events = newSViv (revents);
199 296
200 PUSHMARK (SP); 297 PUSHMARK (SP);
201 EXTEND (SP, 2);
202 PUSHs (sv_self);
203 PUSHs (sv_events); 298 XPUSHs (sv_events);
204 299
205 PUTBACK; 300 PUTBACK;
206 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 301 call_sv ((SV *)arg, G_DISCARD | G_VOID | G_EVAL);
207 302
208 SvREFCNT_dec (sv_self); 303 SvREFCNT_dec ((SV *)arg);
209 304
210 if (sv_events_cache) 305 if (sv_events_cache)
211 SvREFCNT_dec (sv_events); 306 SvREFCNT_dec (sv_events);
212 else 307 else
213 sv_events_cache = sv_events; 308 sv_events_cache = sv_events;
222 317
223 SP = PL_stack_base + mark; 318 SP = PL_stack_base + mark;
224 PUTBACK; 319 PUTBACK;
225} 320}
226 321
227static void
228e_once_cb (int revents, void *arg)
229{
230 dSP;
231 I32 mark = SP - PL_stack_base;
232 SV *sv_events;
233
234 if (sv_events_cache)
235 {
236 sv_events = sv_events_cache; sv_events_cache = 0;
237 SvIV_set (sv_events, revents);
238 }
239 else
240 sv_events = newSViv (revents);
241
242 PUSHMARK (SP);
243 XPUSHs (sv_events);
244
245 PUTBACK;
246 call_sv ((SV *)arg, G_DISCARD | G_VOID | G_EVAL);
247
248 SvREFCNT_dec ((SV *)arg);
249
250 if (sv_events_cache)
251 SvREFCNT_dec (sv_events);
252 else
253 sv_events_cache = sv_events;
254
255 if (SvTRUE (ERRSV))
256 {
257 SPAGAIN;
258 PUSHMARK (SP);
259 PUTBACK;
260 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
261 }
262
263 SP = PL_stack_base + mark;
264 PUTBACK;
265}
266
267static ev_tstamp 322static ev_tstamp
268e_periodic_cb (ev_periodic *w, ev_tstamp now) 323e_periodic_cb (ev_periodic *w, ev_tstamp now)
269{ 324{
270 ev_tstamp retval; 325 ev_tstamp retval;
271 int count; 326 int count;
335 const_iv (EV_, MINPRI) 390 const_iv (EV_, MINPRI)
336 const_iv (EV_, MAXPRI) 391 const_iv (EV_, MAXPRI)
337 392
338 const_iv (EV_, UNDEF) 393 const_iv (EV_, UNDEF)
339 const_iv (EV_, NONE) 394 const_iv (EV_, NONE)
340 const_iv (EV_, TIMEOUT)
341 const_iv (EV_, READ) 395 const_iv (EV_, READ)
342 const_iv (EV_, WRITE) 396 const_iv (EV_, WRITE)
397 const_iv (EV_, IO)
398 const_iv (EV_, TIMEOUT)
399 const_iv (EV_, TIMER)
400 const_iv (EV_, PERIODIC)
343 const_iv (EV_, SIGNAL) 401 const_iv (EV_, SIGNAL)
402 const_iv (EV_, CHILD)
403 const_iv (EV_, STAT)
344 const_iv (EV_, IDLE) 404 const_iv (EV_, IDLE)
405 const_iv (EV_, PREPARE)
345 const_iv (EV_, CHECK) 406 const_iv (EV_, CHECK)
407 const_iv (EV_, EMBED)
408 const_iv (EV_, FORK)
409 const_iv (EV_, ASYNC)
410 const_iv (EV_, CUSTOM)
346 const_iv (EV_, ERROR) 411 const_iv (EV_, ERROR)
347 412
413 const_iv (EV, LOOP_NONBLOCK)
348 const_iv (EV, LOOP_ONESHOT) 414 const_iv (EV, LOOP_ONESHOT)
415
349 const_iv (EV, LOOP_NONBLOCK) 416 const_iv (EV, UNLOOP_CANCEL)
350 const_iv (EV, UNLOOP_ONE) 417 const_iv (EV, UNLOOP_ONE)
351 const_iv (EV, UNLOOP_ALL) 418 const_iv (EV, UNLOOP_ALL)
352 419
353 const_iv (EV, BACKEND_SELECT) 420 const_iv (EV, BACKEND_SELECT)
354 const_iv (EV, BACKEND_POLL) 421 const_iv (EV, BACKEND_POLL)
357 const_iv (EV, BACKEND_DEVPOLL) 424 const_iv (EV, BACKEND_DEVPOLL)
358 const_iv (EV, BACKEND_PORT) 425 const_iv (EV, BACKEND_PORT)
359 const_iv (EV, FLAG_AUTO) 426 const_iv (EV, FLAG_AUTO)
360 const_iv (EV, FLAG_NOENV) 427 const_iv (EV, FLAG_NOENV)
361 const_iv (EV, FLAG_FORKCHECK) 428 const_iv (EV, FLAG_FORKCHECK)
429
430 const_iv (EV_, VERSION_MAJOR)
431 const_iv (EV_, VERSION_MINOR)
362 }; 432 };
363 433
364 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 434 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
365 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 435 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
366 436
375 stash_check = gv_stashpv ("EV::Check" , 1); 445 stash_check = gv_stashpv ("EV::Check" , 1);
376 stash_child = gv_stashpv ("EV::Child" , 1); 446 stash_child = gv_stashpv ("EV::Child" , 1);
377 stash_embed = gv_stashpv ("EV::Embed" , 1); 447 stash_embed = gv_stashpv ("EV::Embed" , 1);
378 stash_stat = gv_stashpv ("EV::Stat" , 1); 448 stash_stat = gv_stashpv ("EV::Stat" , 1);
379 stash_fork = gv_stashpv ("EV::Fork" , 1); 449 stash_fork = gv_stashpv ("EV::Fork" , 1);
450 stash_async = gv_stashpv ("EV::Async" , 1);
380 451
381 { 452 {
382 SV *sv = perl_get_sv ("EV::API", TRUE); 453 SV *sv = perl_get_sv ("EV::API", TRUE);
383 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 454 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
384 455
388 evapi.sv_fileno = sv_fileno; 459 evapi.sv_fileno = sv_fileno;
389 evapi.sv_signum = sv_signum; 460 evapi.sv_signum = sv_signum;
390 evapi.supported_backends = ev_supported_backends (); 461 evapi.supported_backends = ev_supported_backends ();
391 evapi.recommended_backends = ev_recommended_backends (); 462 evapi.recommended_backends = ev_recommended_backends ();
392 evapi.embeddable_backends = ev_embeddable_backends (); 463 evapi.embeddable_backends = ev_embeddable_backends ();
393 evapi.time = ev_time; 464 evapi.time_ = ev_time;
394 evapi.sleep = ev_sleep; 465 evapi.sleep_ = ev_sleep;
395 evapi.loop_new = ev_loop_new; 466 evapi.loop_new = ev_loop_new;
396 evapi.loop_destroy = ev_loop_destroy; 467 evapi.loop_destroy = ev_loop_destroy;
397 evapi.loop_fork = ev_loop_fork; 468 evapi.loop_fork = ev_loop_fork;
398 evapi.loop_count = ev_loop_count; 469 evapi.loop_count = ev_loop_count;
399 evapi.now = ev_now; 470 evapi.now = ev_now;
471 evapi.now_update = ev_now_update;
472 evapi.suspend = ev_suspend;
473 evapi.resume = ev_resume;
400 evapi.backend = ev_backend; 474 evapi.backend = ev_backend;
401 evapi.unloop = ev_unloop; 475 evapi.unloop = ev_unloop;
402 evapi.ref = ev_ref; 476 evapi.ref = ev_ref;
403 evapi.unref = ev_unref; 477 evapi.unref = ev_unref;
404 evapi.loop = ev_loop; 478 evapi.loop = ev_loop;
470 544
471unsigned int ev_recommended_backends () 545unsigned int ev_recommended_backends ()
472 546
473unsigned int ev_embeddable_backends () 547unsigned int ev_embeddable_backends ()
474 548
549void ev_sleep (NV interval)
550
475NV ev_time () 551NV ev_time ()
476 552
477NV ev_now () 553NV ev_now ()
554 C_ARGS: evapi.default_loop
555
556void ev_now_update ()
557 C_ARGS: evapi.default_loop
558
559void ev_suspend ()
560 C_ARGS: evapi.default_loop
561
562void ev_resume ()
478 C_ARGS: evapi.default_loop 563 C_ARGS: evapi.default_loop
479 564
480unsigned int ev_backend () 565unsigned int ev_backend ()
481 C_ARGS: evapi.default_loop 566 C_ARGS: evapi.default_loop
482 567
626 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 711 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval);
627 if (!ix) START (stat, RETVAL); 712 if (!ix) START (stat, RETVAL);
628 OUTPUT: 713 OUTPUT:
629 RETVAL 714 RETVAL
630 715
631ev_embed *embed (struct ev_loop *loop, SV *cb = &PL_sv_undef) 716ev_embed *embed (struct ev_loop *loop, SV *cb = 0)
632 ALIAS: 717 ALIAS:
633 embed_ns = 1 718 embed_ns = 1
634 CODE: 719 CODE:
635{ 720{
636 if (!(ev_backend (loop) & ev_embeddable_backends ())) 721 if (!(ev_backend (loop) & ev_embeddable_backends ()))
637 croak ("passed loop is not embeddable via EV::embed,"); 722 croak ("passed loop is not embeddable via EV::embed,");
638 723
639 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv); 724 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv);
640 RETVAL->fh = newSVsv (ST (0)); 725 RETVAL->fh = newSVsv (ST (0));
641 ev_embed_set (RETVAL, loop); 726 ev_embed_set (RETVAL, loop);
642
643 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
644
645 if (!ix) START (embed, RETVAL); 727 if (!ix) START (embed, RETVAL);
646} 728}
729 OUTPUT:
730 RETVAL
731
732ev_async *async (SV *cb)
733 ALIAS:
734 async_ns = 1
735 CODE:
736 RETVAL = e_new (sizeof (ev_async), cb, default_loop_sv);
737 ev_async_set (RETVAL);
738 if (!ix) START (async, RETVAL);
647 OUTPUT: 739 OUTPUT:
648 RETVAL 740 RETVAL
649 741
650void once (SV *fh, int events, SV *timeout, SV *cb) 742void once (SV *fh, int events, SV *timeout, SV *cb)
651 CODE: 743 CODE:
680 RETVAL = w->e_flags & WFLAG_KEEPALIVE; 772 RETVAL = w->e_flags & WFLAG_KEEPALIVE;
681 new_value = new_value ? WFLAG_KEEPALIVE : 0; 773 new_value = new_value ? WFLAG_KEEPALIVE : 0;
682 774
683 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) 775 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE))
684 { 776 {
777 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value;
685 REF (w); 778 REF (w);
686 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value;
687 UNREF (w); 779 UNREF (w);
688 } 780 }
689} 781}
690 OUTPUT: 782 OUTPUT:
691 RETVAL 783 RETVAL
692 784
693SV *cb (ev_watcher *w, SV *new_cb = 0) 785SV *cb (ev_watcher *w, SV *new_cb = 0)
694 CODE: 786 CODE:
695{ 787{
696 RETVAL = newSVsv (w->cb_sv);
697
698 if (items > 1) 788 if (items > 1)
699 sv_setsv (w->cb_sv, new_cb); 789 {
790 new_cb = e_get_cv (new_cb);
791 RETVAL = newRV_noinc (w->cb_sv);
792 w->cb_sv = SvREFCNT_inc (new_cb);
793 }
794 else
795 RETVAL = newRV_inc (w->cb_sv);
700} 796}
701 OUTPUT: 797 OUTPUT:
702 RETVAL 798 RETVAL
703 799
704SV *data (ev_watcher *w, SV *new_data = 0) 800SV *data (ev_watcher *w, SV *new_data = 0)
862 958
863void ev_timer_again (ev_timer *w) 959void ev_timer_again (ev_timer *w)
864 INIT: 960 INIT:
865 CHECK_REPEAT (w->repeat); 961 CHECK_REPEAT (w->repeat);
866 CODE: 962 CODE:
867 REF (w);
868 ev_timer_again (e_loop (w), w); 963 ev_timer_again (e_loop (w), w);
869 UNREF (w); 964 UNREF (w);
870 965
871void DESTROY (ev_timer *w) 966void DESTROY (ev_timer *w)
872 CODE: 967 CODE:
877 INIT: 972 INIT:
878 CHECK_REPEAT (repeat); 973 CHECK_REPEAT (repeat);
879 CODE: 974 CODE:
880 RESET (timer, w, (w, after, repeat)); 975 RESET (timer, w, (w, after, repeat));
881 976
882NV at (ev_timer *w)
883 CODE:
884 RETVAL = w->at;
885 OUTPUT:
886 RETVAL
887
888MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 977MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
889 978
890void ev_periodic_start (ev_periodic *w) 979void ev_periodic_start (ev_periodic *w)
891 INIT: 980 INIT:
892 CHECK_REPEAT (w->interval); 981 CHECK_REPEAT (w->interval);
897 CODE: 986 CODE:
898 STOP (periodic, w); 987 STOP (periodic, w);
899 988
900void ev_periodic_again (ev_periodic *w) 989void ev_periodic_again (ev_periodic *w)
901 CODE: 990 CODE:
902 REF (w);
903 ev_periodic_again (e_loop (w), w); 991 ev_periodic_again (e_loop (w), w);
904 UNREF (w); 992 UNREF (w);
905 993
906void DESTROY (ev_periodic *w) 994void DESTROY (ev_periodic *w)
907 CODE: 995 CODE:
919 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 1007 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0));
920} 1008}
921 1009
922NV at (ev_periodic *w) 1010NV at (ev_periodic *w)
923 CODE: 1011 CODE:
924 RETVAL = w->at; 1012 RETVAL = ev_periodic_at (w);
925 OUTPUT: 1013 OUTPUT:
926 RETVAL 1014 RETVAL
927 1015
928MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 1016MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
929 1017
1135 CODE: 1223 CODE:
1136 RETVAL = newSVsv (w->fh); 1224 RETVAL = newSVsv (w->fh);
1137 OUTPUT: 1225 OUTPUT:
1138 RETVAL 1226 RETVAL
1139 1227
1228void ev_embed_sweep (ev_embed *w)
1229 C_ARGS: e_loop (w), w
1230
1231MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_
1232
1233void ev_async_start (ev_async *w)
1234 CODE:
1235 START (async, w);
1236
1237void ev_async_stop (ev_async *w)
1238 CODE:
1239 STOP (async, w);
1240
1241void DESTROY (ev_async *w)
1242 CODE:
1243 STOP (async, w);
1244 e_destroy (w);
1245
1246void ev_async_send (ev_async *w)
1247 C_ARGS: e_loop (w), w
1248
1249SV *ev_async_async_pending (ev_async *w)
1250 CODE:
1251 RETVAL = boolSV (ev_async_pending (w));
1252 OUTPUT:
1253 RETVAL
1254
1140MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ 1255MODULE = EV PACKAGE = EV::Loop PREFIX = ev_
1141 1256
1142SV *new (SV *klass, unsigned int flags = 0) 1257SV *new (SV *klass, unsigned int flags = 0)
1143 CODE: 1258 CODE:
1144{ 1259{
1157 if (loop != evapi.default_loop) /* global destruction sucks */ 1272 if (loop != evapi.default_loop) /* global destruction sucks */
1158 ev_loop_destroy (loop); 1273 ev_loop_destroy (loop);
1159 1274
1160void ev_loop_fork (struct ev_loop *loop) 1275void ev_loop_fork (struct ev_loop *loop)
1161 1276
1277void ev_loop_verify (struct ev_loop *loop)
1278
1162NV ev_now (struct ev_loop *loop) 1279NV ev_now (struct ev_loop *loop)
1280
1281void ev_now_update (struct ev_loop *loop)
1282
1283void ev_suspend (struct ev_loop *loop)
1284
1285void ev_resume (struct ev_loop *loop)
1163 1286
1164void ev_set_io_collect_interval (struct ev_loop *loop, NV interval) 1287void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1165 1288
1166void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) 1289void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1167 1290
1311 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 1434 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval);
1312 if (!ix) START (stat, RETVAL); 1435 if (!ix) START (stat, RETVAL);
1313 OUTPUT: 1436 OUTPUT:
1314 RETVAL 1437 RETVAL
1315 1438
1316ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = &PL_sv_undef) 1439ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0)
1317 ALIAS: 1440 ALIAS:
1318 embed_ns = 1 1441 embed_ns = 1
1319 CODE: 1442 CODE:
1320{ 1443{
1321 if (!(ev_backend (other) & ev_embeddable_backends ())) 1444 if (!(ev_backend (other) & ev_embeddable_backends ()))
1322 croak ("passed loop is not embeddable via EV::embed,"); 1445 croak ("passed loop is not embeddable via EV::embed,");
1323 1446
1324 RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); 1447 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1325 RETVAL->fh = newSVsv (ST (1)); 1448 RETVAL->fh = newSVsv (ST (1));
1326 ev_embed_set (RETVAL, other); 1449 ev_embed_set (RETVAL, other);
1327
1328 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
1329
1330 if (!ix) START (embed, RETVAL); 1450 if (!ix) START (embed, RETVAL);
1331} 1451}
1452 OUTPUT:
1453 RETVAL
1454
1455ev_async *async (struct ev_loop *loop, SV *cb)
1456 ALIAS:
1457 async_ns = 1
1458 CODE:
1459 RETVAL = e_new (sizeof (ev_async), cb, ST (0));
1460 ev_async_set (RETVAL);
1461 if (!ix) START (async, RETVAL);
1332 OUTPUT: 1462 OUTPUT:
1333 RETVAL 1463 RETVAL
1334 1464
1335void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) 1465void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1336 CODE: 1466 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines