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.138 by root, Wed Apr 14 00:17:22 2010 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/* fix perl api breakage */
6#undef signal
7#undef sigaction
6 8
9#include "schmorp.h"
10
11/* old API compatibility */
12static int
13sv_fileno (SV *fh)
14{
15 return s_fileno (fh, 0);
16}
17
18#define EV_STANDALONE 1
7#define EV_PROTOTYPES 1 19#define EV_PROTOTYPES 1
8#define EV_USE_NANOSLEEP EV_USE_MONOTONIC 20#define EV_USE_NANOSLEEP EV_USE_MONOTONIC
9#define EV_H <ev.h> 21#define EV_H <ev.h>
22#define EV_CONFIG_H error
10#include "EV/EVAPI.h" 23#include "EV/EVAPI.h"
11
12/* fix perl api breakage */
13#undef signal
14#undef sigaction
15 24
16#define EV_SELECT_IS_WINSOCKET 0 25#define EV_SELECT_IS_WINSOCKET 0
17#ifdef _WIN32 26#ifdef _WIN32
18# define EV_SELECT_USE_FD_SET 0 27# define EV_SELECT_USE_FD_SET 0
19# define NFDBITS PERL_NFDBITS 28# define NFDBITS PERL_NFDBITS
24 33
25#ifndef _WIN32 34#ifndef _WIN32
26# include <pthread.h> 35# include <pthread.h>
27#endif 36#endif
28 37
29#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX ((w)->loop)) 38#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(w))->loop))
39#define e_flags(w) ((ev_watcher *)(w))->e_flags
40#define e_self(w) ((ev_watcher *)(w))->self
41#define e_fh(w) ((ev_watcher *)(w))->fh
42#define e_data(w) ((ev_watcher *)(w))->data
30 43
31#define WFLAG_KEEPALIVE 1 44#define WFLAG_KEEPALIVE 1
45#define WFLAG_UNREFED 2 /* has been unref'ed */
32 46
33#define UNREF(w) \ 47#define UNREF(w) \
34 if (!((w)->e_flags & WFLAG_KEEPALIVE) \ 48 if (!(e_flags (w) & (WFLAG_KEEPALIVE | WFLAG_UNREFED)) \
35 && !ev_is_active (w)) \ 49 && ev_is_active (w)) \
50 { \
36 ev_unref (e_loop (w)); 51 ev_unref (e_loop (w)); \
52 e_flags (w) |= WFLAG_UNREFED; \
53 }
37 54
38#define REF(w) \ 55#define REF(w) \
39 if (!((w)->e_flags & WFLAG_KEEPALIVE) \ 56 if (e_flags (w) & WFLAG_UNREFED) \
40 && ev_is_active (w)) \ 57 { \
58 e_flags (w) &= ~WFLAG_UNREFED; \
41 ev_ref (e_loop (w)); 59 ev_ref (e_loop (w)); \
60 }
42 61
43#define START(type,w) \ 62#define START(type,w) \
44 do { \ 63 do { \
64 ev_ ## type ## _start (e_loop (w), w); \
45 UNREF (w); \ 65 UNREF (w); \
46 ev_ ## type ## _start (e_loop (w), w); \
47 } while (0) 66 } while (0)
48 67
49#define STOP(type,w) \ 68#define STOP(type,w) \
50 do { \ 69 do { \
51 REF (w); \ 70 REF (w); \
52 ev_ ## type ## _stop (e_loop (w), w); \ 71 ev_ ## type ## _stop (e_loop (w), w); \
53 } while (0) 72 } while (0)
54 73
55#define RESET(type,w,seta) \ 74#define RESET(type,w,seta) \
56 do { \ 75 do { \
57 int active = ev_is_active (w); \ 76 int active = ev_is_active (w); \
58 if (active) STOP (type, w); \ 77 if (active) STOP (type, w); \
59 ev_ ## type ## _set seta; \ 78 ev_ ## type ## _set seta; \
60 if (active) START (type, w); \ 79 if (active) START (type, w); \
61 } while (0) 80 } while (0)
62 81
63typedef int Signal; 82typedef 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)
64 106
65static SV *default_loop_sv; 107static SV *default_loop_sv;
66 108
67static struct EVAPI evapi; 109static struct EVAPI evapi;
68 110
77 *stash_stat, 119 *stash_stat,
78 *stash_idle, 120 *stash_idle,
79 *stash_prepare, 121 *stash_prepare,
80 *stash_check, 122 *stash_check,
81 *stash_embed, 123 *stash_embed,
82 *stash_fork; 124 *stash_fork,
83 125 *stash_async;
84#ifndef SIG_SIZE
85/* kudos to Slaven Rezic for the idea */
86static char sig_size [] = { SIG_NUM };
87# define SIG_SIZE (sizeof (sig_size) + 1)
88#endif
89
90static Signal
91sv_signum (SV *sig)
92{
93 Signal signum;
94
95 SvGETMAGIC (sig);
96
97 for (signum = 1; signum < SIG_SIZE; ++signum)
98 if (strEQ (SvPV_nolen (sig), PL_sig_name [signum]))
99 return signum;
100
101 signum = SvIV (sig);
102
103 if (signum > 0 && signum < SIG_SIZE)
104 return signum;
105
106 return -1;
107}
108 126
109///////////////////////////////////////////////////////////////////////////// 127/////////////////////////////////////////////////////////////////////////////
110// Event 128// Event
111 129
112static void e_cb (EV_P_ ev_watcher *w, int revents); 130static void e_cb (EV_P_ ev_watcher *w, int revents);
113 131
114static int 132void *
115sv_fileno (SV *fh)
116{
117 SvGETMAGIC (fh);
118
119 if (SvROK (fh))
120 fh = SvRV (fh);
121
122 if (SvTYPE (fh) == SVt_PVGV)
123 return PerlIO_fileno (IoIFP (sv_2io (fh)));
124
125 if (SvOK (fh) && (SvIV (fh) >= 0) && (SvIV (fh) < 0x7fffffffL))
126 return SvIV (fh);
127
128 return -1;
129}
130
131static void *
132e_new (int size, SV *cb_sv, SV *loop) 133e_new (int size, SV *cb_sv, SV *loop)
133{ 134{
135 SV *cv = cb_sv ? s_get_cv_croak (cb_sv) : 0;
134 ev_watcher *w; 136 ev_watcher *w;
135 SV *self = NEWSV (0, size); 137 SV *self = NEWSV (0, size);
136 SvPOK_only (self); 138 SvPOK_only (self);
137 SvCUR_set (self, size); 139 SvCUR_set (self, size);
138 140
139 w = (ev_watcher *)SvPVX (self); 141 w = (ev_watcher *)SvPVX (self);
140 142
141 ev_init (w, e_cb); 143 ev_init (w, cv ? e_cb : 0);
142 144
143 w->loop = SvREFCNT_inc (SvRV (loop)); 145 w->loop = SvREFCNT_inc (SvRV (loop));
144 w->e_flags = WFLAG_KEEPALIVE; 146 w->e_flags = WFLAG_KEEPALIVE;
145 w->data = 0; 147 w->data = 0;
146 w->fh = 0; 148 w->fh = 0;
147 w->cb_sv = SvTEMP (cb_sv) && SvREFCNT (cb_sv) == 1 ? SvREFCNT_inc (cb_sv) : newSVsv (cb_sv); 149 w->cb_sv = SvREFCNT_inc (cv);
148 w->self = self; 150 w->self = self;
149 151
150 return (void *)w; 152 return (void *)w;
151} 153}
152 154
176 } 178 }
177 179
178 return rv; 180 return rv;
179} 181}
180 182
181static SV *sv_events_cache; 183static SV *sv_self_cache, *sv_events_cache;
182 184
183static void 185static void
184e_cb (EV_P_ ev_watcher *w, int revents) 186e_cb (EV_P_ ev_watcher *w, int revents)
185{ 187{
186 dSP; 188 dSP;
187 I32 mark = SP - PL_stack_base; 189 I32 mark = SP - PL_stack_base;
188 SV *sv_self, *sv_events; 190 SV *sv_self, *sv_events;
189 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 {
190 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ 204 sv_self = newRV_inc (w->self); /* e_self (w) MUST be blessed by now */
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
253static void
254e_once_cb (int revents, void *arg)
255{
256 dSP;
257 I32 mark = SP - PL_stack_base;
258 SV *sv_events;
191 259
192 if (sv_events_cache) 260 if (sv_events_cache)
193 { 261 {
194 sv_events = sv_events_cache; sv_events_cache = 0; 262 sv_events = sv_events_cache; sv_events_cache = 0;
195 SvIV_set (sv_events, revents); 263 SvIV_set (sv_events, revents);
196 } 264 }
197 else 265 else
198 sv_events = newSViv (revents); 266 sv_events = newSViv (revents);
199 267
200 PUSHMARK (SP); 268 PUSHMARK (SP);
201 EXTEND (SP, 2);
202 PUSHs (sv_self);
203 PUSHs (sv_events); 269 XPUSHs (sv_events);
204 270
205 PUTBACK; 271 PUTBACK;
206 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 272 call_sv ((SV *)arg, G_DISCARD | G_VOID | G_EVAL);
207 273
208 SvREFCNT_dec (sv_self); 274 SvREFCNT_dec ((SV *)arg);
209 275
210 if (sv_events_cache) 276 if (sv_events_cache)
211 SvREFCNT_dec (sv_events); 277 SvREFCNT_dec (sv_events);
212 else 278 else
213 sv_events_cache = sv_events; 279 sv_events_cache = sv_events;
222 288
223 SP = PL_stack_base + mark; 289 SP = PL_stack_base + mark;
224 PUTBACK; 290 PUTBACK;
225} 291}
226 292
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 293static ev_tstamp
268e_periodic_cb (ev_periodic *w, ev_tstamp now) 294e_periodic_cb (ev_periodic *w, ev_tstamp now)
269{ 295{
270 ev_tstamp retval; 296 ev_tstamp retval;
271 int count; 297 int count;
274 ENTER; 300 ENTER;
275 SAVETMPS; 301 SAVETMPS;
276 302
277 PUSHMARK (SP); 303 PUSHMARK (SP);
278 EXTEND (SP, 2); 304 EXTEND (SP, 2);
279 PUSHs (newRV_inc (w->self)); /* w->self MUST be blessed by now */ 305 PUSHs (newRV_inc (e_self (w))); /* e_self (w) MUST be blessed by now */
280 PUSHs (newSVnv (now)); 306 PUSHs (newSVnv (now));
281 307
282 PUTBACK; 308 PUTBACK;
283 count = call_sv (w->fh, G_SCALAR | G_EVAL); 309 count = call_sv (w->fh, G_SCALAR | G_EVAL);
284 SPAGAIN; 310 SPAGAIN;
335 const_iv (EV_, MINPRI) 361 const_iv (EV_, MINPRI)
336 const_iv (EV_, MAXPRI) 362 const_iv (EV_, MAXPRI)
337 363
338 const_iv (EV_, UNDEF) 364 const_iv (EV_, UNDEF)
339 const_iv (EV_, NONE) 365 const_iv (EV_, NONE)
340 const_iv (EV_, TIMEOUT)
341 const_iv (EV_, READ) 366 const_iv (EV_, READ)
342 const_iv (EV_, WRITE) 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)
343 const_iv (EV_, SIGNAL) 372 const_iv (EV_, SIGNAL)
373 const_iv (EV_, CHILD)
374 const_iv (EV_, STAT)
344 const_iv (EV_, IDLE) 375 const_iv (EV_, IDLE)
376 const_iv (EV_, PREPARE)
345 const_iv (EV_, CHECK) 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)
346 const_iv (EV_, ERROR) 382 const_iv (EV_, ERROR)
347 383
384 const_iv (EV, LOOP_NONBLOCK)
348 const_iv (EV, LOOP_ONESHOT) 385 const_iv (EV, LOOP_ONESHOT)
386
349 const_iv (EV, LOOP_NONBLOCK) 387 const_iv (EV, UNLOOP_CANCEL)
350 const_iv (EV, UNLOOP_ONE) 388 const_iv (EV, UNLOOP_ONE)
351 const_iv (EV, UNLOOP_ALL) 389 const_iv (EV, UNLOOP_ALL)
352 390
353 const_iv (EV, BACKEND_SELECT) 391 const_iv (EV, BACKEND_SELECT)
354 const_iv (EV, BACKEND_POLL) 392 const_iv (EV, BACKEND_POLL)
355 const_iv (EV, BACKEND_EPOLL) 393 const_iv (EV, BACKEND_EPOLL)
356 const_iv (EV, BACKEND_KQUEUE) 394 const_iv (EV, BACKEND_KQUEUE)
357 const_iv (EV, BACKEND_DEVPOLL) 395 const_iv (EV, BACKEND_DEVPOLL)
358 const_iv (EV, BACKEND_PORT) 396 const_iv (EV, BACKEND_PORT)
397 const_iv (EV, BACKEND_ALL)
359 const_iv (EV, FLAG_AUTO) 398 const_iv (EV, FLAG_AUTO)
399 const_iv (EV, FLAG_FORKCHECK)
400 const_iv (EV, FLAG_SIGNALFD)
360 const_iv (EV, FLAG_NOENV) 401 const_iv (EV, FLAG_NOENV)
402 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
361 const_iv (EV, FLAG_FORKCHECK) 403 const_iv (EV, FLAG_NOINOTIFY)
404
405 const_iv (EV_, VERSION_MAJOR)
406 const_iv (EV_, VERSION_MINOR)
362 }; 407 };
363 408
364 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 409 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
365 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 410 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
366 411
375 stash_check = gv_stashpv ("EV::Check" , 1); 420 stash_check = gv_stashpv ("EV::Check" , 1);
376 stash_child = gv_stashpv ("EV::Child" , 1); 421 stash_child = gv_stashpv ("EV::Child" , 1);
377 stash_embed = gv_stashpv ("EV::Embed" , 1); 422 stash_embed = gv_stashpv ("EV::Embed" , 1);
378 stash_stat = gv_stashpv ("EV::Stat" , 1); 423 stash_stat = gv_stashpv ("EV::Stat" , 1);
379 stash_fork = gv_stashpv ("EV::Fork" , 1); 424 stash_fork = gv_stashpv ("EV::Fork" , 1);
425 stash_async = gv_stashpv ("EV::Async" , 1);
380 426
381 { 427 {
382 SV *sv = perl_get_sv ("EV::API", TRUE); 428 SV *sv = perl_get_sv ("EV::API", TRUE);
383 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 429 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
384 430
385 /* the poor man's shared library emulator */ 431 /* the poor man's shared library emulator */
386 evapi.ver = EV_API_VERSION; 432 evapi.ver = EV_API_VERSION;
387 evapi.rev = EV_API_REVISION; 433 evapi.rev = EV_API_REVISION;
388 evapi.sv_fileno = sv_fileno; 434 evapi.sv_fileno = sv_fileno;
389 evapi.sv_signum = sv_signum; 435 evapi.sv_signum = s_signum;
390 evapi.supported_backends = ev_supported_backends (); 436 evapi.supported_backends = ev_supported_backends ();
391 evapi.recommended_backends = ev_recommended_backends (); 437 evapi.recommended_backends = ev_recommended_backends ();
392 evapi.embeddable_backends = ev_embeddable_backends (); 438 evapi.embeddable_backends = ev_embeddable_backends ();
393 evapi.time = ev_time; 439 evapi.time_ = ev_time;
394 evapi.sleep = ev_sleep; 440 evapi.sleep_ = ev_sleep;
395 evapi.loop_new = ev_loop_new; 441 evapi.loop_new = ev_loop_new;
396 evapi.loop_destroy = ev_loop_destroy; 442 evapi.loop_destroy = ev_loop_destroy;
397 evapi.loop_fork = ev_loop_fork; 443 evapi.loop_fork = ev_loop_fork;
398 evapi.loop_count = ev_loop_count; 444 evapi.iteration = ev_iteration;
445 evapi.depth = ev_depth;
446 evapi.set_userdata = ev_set_userdata;
447 evapi.userdata = ev_userdata;
399 evapi.now = ev_now; 448 evapi.now = ev_now;
449 evapi.now_update = ev_now_update;
450 evapi.suspend = ev_suspend;
451 evapi.resume = ev_resume;
400 evapi.backend = ev_backend; 452 evapi.backend = ev_backend;
401 evapi.unloop = ev_unloop; 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;
402 evapi.ref = ev_ref; 459 evapi.ref = ev_ref;
403 evapi.unref = ev_unref; 460 evapi.unref = ev_unref;
404 evapi.loop = ev_loop; 461 evapi.loop = ev_loop;
405 evapi.once = ev_once; 462 evapi.once = ev_once;
406 evapi.io_start = ev_io_start; 463 evapi.io_start = ev_io_start;
407 evapi.io_stop = ev_io_stop; 464 evapi.io_stop = ev_io_stop;
408 evapi.timer_start = ev_timer_start; 465 evapi.timer_start = ev_timer_start;
409 evapi.timer_stop = ev_timer_stop; 466 evapi.timer_stop = ev_timer_stop;
410 evapi.timer_again = ev_timer_again; 467 evapi.timer_again = ev_timer_again;
468 evapi.timer_remaining = ev_timer_remaining;
411 evapi.periodic_start = ev_periodic_start; 469 evapi.periodic_start = ev_periodic_start;
412 evapi.periodic_stop = ev_periodic_stop; 470 evapi.periodic_stop = ev_periodic_stop;
413 evapi.signal_start = ev_signal_start; 471 evapi.signal_start = ev_signal_start;
414 evapi.signal_stop = ev_signal_stop; 472 evapi.signal_stop = ev_signal_stop;
415 evapi.idle_start = ev_idle_start; 473 evapi.idle_start = ev_idle_start;
470 528
471unsigned int ev_recommended_backends () 529unsigned int ev_recommended_backends ()
472 530
473unsigned int ev_embeddable_backends () 531unsigned int ev_embeddable_backends ()
474 532
533void ev_sleep (NV interval)
534
475NV ev_time () 535NV ev_time ()
476 536
477NV ev_now () 537NV ev_now ()
478 C_ARGS: evapi.default_loop 538 C_ARGS: evapi.default_loop
479 539
540void ev_now_update ()
541 C_ARGS: evapi.default_loop
542
543void ev_suspend ()
544 C_ARGS: evapi.default_loop
545
546void ev_resume ()
547 C_ARGS: evapi.default_loop
548
480unsigned int ev_backend () 549unsigned int ev_backend ()
481 C_ARGS: evapi.default_loop 550 C_ARGS: evapi.default_loop
482 551
552void ev_verify ()
553 C_ARGS: evapi.default_loop
554
555unsigned int ev_iteration ()
556 C_ARGS: evapi.default_loop
557
483unsigned int ev_loop_count () 558unsigned int ev_depth ()
484 C_ARGS: evapi.default_loop 559 C_ARGS: evapi.default_loop
485 560
486void ev_set_io_collect_interval (NV interval) 561void ev_set_io_collect_interval (NV interval)
487 C_ARGS: evapi.default_loop, interval 562 C_ARGS: evapi.default_loop, interval
488 563
499 C_ARGS: evapi.default_loop, fd, revents 574 C_ARGS: evapi.default_loop, fd, revents
500 575
501void ev_feed_signal_event (SV *signal) 576void ev_feed_signal_event (SV *signal)
502 CODE: 577 CODE:
503{ 578{
504 Signal signum = sv_signum (signal); 579 Signal signum = s_signum (signal);
505 CHECK_SIG (signal, signum); 580 CHECK_SIG (signal, signum);
506 581
507 ev_feed_signal_event (evapi.default_loop, signum); 582 ev_feed_signal_event (evapi.default_loop, signum);
508} 583}
509 584
585unsigned int ev_pending_count ()
586 C_ARGS: evapi.default_loop
587
588void ev_invoke_pending ()
589 C_ARGS: evapi.default_loop
590
510ev_io *io (SV *fh, int events, SV *cb) 591ev_io *io (SV *fh, int events, SV *cb)
511 ALIAS: 592 ALIAS:
512 io_ns = 1 593 io_ns = 1
594 _ae_io = 2
513 CODE: 595 CODE:
514{ 596{
515 int fd = sv_fileno (fh); 597 int fd = s_fileno (fh, events & EV_WRITE);
516 CHECK_FD (fh, fd); 598 CHECK_FD (fh, fd);
517 599
600 if (ix == 2)
601 {
602 ix = 0;
603 events = events ? EV_WRITE : EV_READ;
604 }
605
518 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv); 606 RETVAL = e_new (sizeof (ev_io), cb, default_loop_sv);
519 RETVAL->fh = newSVsv (fh); 607 e_fh (RETVAL) = newSVsv (fh);
520 ev_io_set (RETVAL, fd, events); 608 ev_io_set (RETVAL, fd, events);
521 if (!ix) START (io, RETVAL); 609 if (!ix) START (io, RETVAL);
522} 610}
523 OUTPUT: 611 OUTPUT:
524 RETVAL 612 RETVAL
542 CHECK_REPEAT (interval); 630 CHECK_REPEAT (interval);
543 CODE: 631 CODE:
544{ 632{
545 ev_periodic *w; 633 ev_periodic *w;
546 w = e_new (sizeof (ev_periodic), cb, default_loop_sv); 634 w = e_new (sizeof (ev_periodic), cb, default_loop_sv);
547 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 635 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
548 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 636 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
549 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 637 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
550 if (!ix) START (periodic, w); 638 if (!ix) START (periodic, w);
551} 639}
552 OUTPUT: 640 OUTPUT:
553 RETVAL 641 RETVAL
555ev_signal *signal (SV *signal, SV *cb) 643ev_signal *signal (SV *signal, SV *cb)
556 ALIAS: 644 ALIAS:
557 signal_ns = 1 645 signal_ns = 1
558 CODE: 646 CODE:
559{ 647{
560 Signal signum = sv_signum (signal); 648 Signal signum = s_signum (signal);
561 CHECK_SIG (signal, signum); 649 CHECK_SIG (signal, signum);
562 650
563 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv); 651 RETVAL = e_new (sizeof (ev_signal), cb, default_loop_sv);
564 ev_signal_set (RETVAL, signum); 652 ev_signal_set (RETVAL, signum);
565 if (!ix) START (signal, RETVAL); 653 if (!ix) START_SIGNAL (RETVAL);
566} 654}
567 OUTPUT: 655 OUTPUT:
568 RETVAL 656 RETVAL
569 657
570ev_idle *idle (SV *cb) 658ev_idle *idle (SV *cb)
620ev_stat *stat (SV *path, NV interval, SV *cb) 708ev_stat *stat (SV *path, NV interval, SV *cb)
621 ALIAS: 709 ALIAS:
622 stat_ns = 1 710 stat_ns = 1
623 CODE: 711 CODE:
624 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv); 712 RETVAL = e_new (sizeof (ev_stat), cb, default_loop_sv);
625 RETVAL->fh = newSVsv (path); 713 e_fh (RETVAL) = newSVsv (path);
626 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 714 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
627 if (!ix) START (stat, RETVAL); 715 if (!ix) START (stat, RETVAL);
628 OUTPUT: 716 OUTPUT:
629 RETVAL 717 RETVAL
630 718
631ev_embed *embed (struct ev_loop *loop, SV *cb = &PL_sv_undef) 719ev_embed *embed (struct ev_loop *loop, SV *cb = 0)
632 ALIAS: 720 ALIAS:
633 embed_ns = 1 721 embed_ns = 1
634 CODE: 722 CODE:
635{ 723{
636 if (!(ev_backend (loop) & ev_embeddable_backends ())) 724 if (!(ev_backend (loop) & ev_embeddable_backends ()))
637 croak ("passed loop is not embeddable via EV::embed,"); 725 croak ("passed loop is not embeddable via EV::embed,");
638 726
639 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv); 727 RETVAL = e_new (sizeof (ev_embed), cb, default_loop_sv);
640 RETVAL->fh = newSVsv (ST (0)); 728 e_fh (RETVAL) = newSVsv (ST (0));
641 ev_embed_set (RETVAL, loop); 729 ev_embed_set (RETVAL, loop);
642
643 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
644
645 if (!ix) START (embed, RETVAL); 730 if (!ix) START (embed, RETVAL);
646} 731}
732 OUTPUT:
733 RETVAL
734
735ev_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);
647 OUTPUT: 742 OUTPUT:
648 RETVAL 743 RETVAL
649 744
650void once (SV *fh, int events, SV *timeout, SV *cb) 745void once (SV *fh, int events, SV *timeout, SV *cb)
651 CODE: 746 CODE:
652 ev_once ( 747 ev_once (
653 evapi.default_loop, 748 evapi.default_loop,
654 sv_fileno (fh), events, 749 s_fileno (fh, events & EV_WRITE), events,
655 SvOK (timeout) ? SvNV (timeout) : -1., 750 SvOK (timeout) ? SvNV (timeout) : -1.,
656 e_once_cb, 751 e_once_cb,
657 newSVsv (cb) 752 newSVsv (cb)
658 ); 753 );
659 754
680 RETVAL = w->e_flags & WFLAG_KEEPALIVE; 775 RETVAL = w->e_flags & WFLAG_KEEPALIVE;
681 new_value = new_value ? WFLAG_KEEPALIVE : 0; 776 new_value = new_value ? WFLAG_KEEPALIVE : 0;
682 777
683 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE)) 778 if (items > 1 && ((new_value ^ w->e_flags) & WFLAG_KEEPALIVE))
684 { 779 {
780 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value;
685 REF (w); 781 REF (w);
686 w->e_flags = (w->e_flags & ~WFLAG_KEEPALIVE) | new_value;
687 UNREF (w); 782 UNREF (w);
688 } 783 }
689} 784}
690 OUTPUT: 785 OUTPUT:
691 RETVAL 786 RETVAL
692 787
693SV *cb (ev_watcher *w, SV *new_cb = 0) 788SV *cb (ev_watcher *w, SV *new_cb = 0)
694 CODE: 789 CODE:
695{ 790{
696 RETVAL = newSVsv (w->cb_sv);
697
698 if (items > 1) 791 if (items > 1)
699 sv_setsv (w->cb_sv, new_cb); 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);
700} 799}
701 OUTPUT: 800 OUTPUT:
702 RETVAL 801 RETVAL
703 802
704SV *data (ev_watcher *w, SV *new_data = 0) 803SV *data (ev_watcher *w, SV *new_data = 0)
769 e_destroy (w); 868 e_destroy (w);
770 869
771void set (ev_io *w, SV *fh, int events) 870void set (ev_io *w, SV *fh, int events)
772 CODE: 871 CODE:
773{ 872{
774 int fd = sv_fileno (fh); 873 int fd = s_fileno (fh, events & EV_WRITE);
775 CHECK_FD (fh, fd); 874 CHECK_FD (fh, fd);
776 875
777 sv_setsv (w->fh, fh); 876 sv_setsv (e_fh (w), fh);
778 RESET (io, w, (w, fd, events)); 877 RESET (io, w, (w, fd, events));
779} 878}
780 879
781SV *fh (ev_io *w, SV *new_fh = 0) 880SV *fh (ev_io *w, SV *new_fh = 0)
782 CODE: 881 CODE:
783{ 882{
784 if (items > 1) 883 if (items > 1)
785 { 884 {
786 int fd = sv_fileno (new_fh); 885 int fd = s_fileno (new_fh, w->events & EV_WRITE);
787 CHECK_FD (new_fh, fd); 886 CHECK_FD (new_fh, fd);
788 887
789 RETVAL = w->fh; 888 RETVAL = e_fh (w);
790 w->fh = newSVsv (new_fh); 889 e_fh (w) = newSVsv (new_fh);
791 890
792 RESET (io, w, (w, fd, w->events)); 891 RESET (io, w, (w, fd, w->events));
793 } 892 }
794 else 893 else
795 RETVAL = newSVsv (w->fh); 894 RETVAL = newSVsv (e_fh (w));
796} 895}
797 OUTPUT: 896 OUTPUT:
798 RETVAL 897 RETVAL
799 898
800int events (ev_io *w, int new_events = EV_UNDEF) 899int events (ev_io *w, int new_events = EV_UNDEF)
810 909
811MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_ 910MODULE = EV PACKAGE = EV::Signal PREFIX = ev_signal_
812 911
813void ev_signal_start (ev_signal *w) 912void ev_signal_start (ev_signal *w)
814 CODE: 913 CODE:
815 START (signal, w); 914 START_SIGNAL (w);
816 915
817void ev_signal_stop (ev_signal *w) 916void ev_signal_stop (ev_signal *w)
818 CODE: 917 CODE:
819 STOP (signal, w); 918 STOP (signal, w);
820 919
824 e_destroy (w); 923 e_destroy (w);
825 924
826void set (ev_signal *w, SV *signal) 925void set (ev_signal *w, SV *signal)
827 CODE: 926 CODE:
828{ 927{
829 Signal signum = sv_signum (signal); 928 Signal signum = s_signum (signal);
830 CHECK_SIG (signal, signum); 929 CHECK_SIG (signal, signum);
831 930
832 RESET (signal, w, (w, signum)); 931 RESET_SIGNAL (w, (w, signum));
833} 932}
834 933
835int signal (ev_signal *w, SV *new_signal = 0) 934int signal (ev_signal *w, SV *new_signal = 0)
836 CODE: 935 CODE:
837{ 936{
838 RETVAL = w->signum; 937 RETVAL = w->signum;
839 938
840 if (items > 1) 939 if (items > 1)
841 { 940 {
842 Signal signum = sv_signum (new_signal); 941 Signal signum = s_signum (new_signal);
843 CHECK_SIG (new_signal, signum); 942 CHECK_SIG (new_signal, signum);
844 943
845 RESET (signal, w, (w, signum)); 944 RESET_SIGNAL (w, (w, signum));
846 } 945 }
847} 946}
848 OUTPUT: 947 OUTPUT:
849 RETVAL 948 RETVAL
850 949
862 961
863void ev_timer_again (ev_timer *w) 962void ev_timer_again (ev_timer *w)
864 INIT: 963 INIT:
865 CHECK_REPEAT (w->repeat); 964 CHECK_REPEAT (w->repeat);
866 CODE: 965 CODE:
867 REF (w);
868 ev_timer_again (e_loop (w), w); 966 ev_timer_again (e_loop (w), w);
869 UNREF (w); 967 UNREF (w);
968
969NV ev_timer_remaining (ev_timer *w)
970 C_ARGS: e_loop (w), w
870 971
871void DESTROY (ev_timer *w) 972void DESTROY (ev_timer *w)
872 CODE: 973 CODE:
873 STOP (timer, w); 974 STOP (timer, w);
874 e_destroy (w); 975 e_destroy (w);
877 INIT: 978 INIT:
878 CHECK_REPEAT (repeat); 979 CHECK_REPEAT (repeat);
879 CODE: 980 CODE:
880 RESET (timer, w, (w, after, repeat)); 981 RESET (timer, w, (w, after, repeat));
881 982
882NV at (ev_timer *w)
883 CODE:
884 RETVAL = w->at;
885 OUTPUT:
886 RETVAL
887
888MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_ 983MODULE = EV PACKAGE = EV::Periodic PREFIX = ev_periodic_
889 984
890void ev_periodic_start (ev_periodic *w) 985void ev_periodic_start (ev_periodic *w)
891 INIT: 986 INIT:
892 CHECK_REPEAT (w->interval); 987 CHECK_REPEAT (w->interval);
897 CODE: 992 CODE:
898 STOP (periodic, w); 993 STOP (periodic, w);
899 994
900void ev_periodic_again (ev_periodic *w) 995void ev_periodic_again (ev_periodic *w)
901 CODE: 996 CODE:
902 REF (w);
903 ev_periodic_again (e_loop (w), w); 997 ev_periodic_again (e_loop (w), w);
904 UNREF (w); 998 UNREF (w);
905 999
906void DESTROY (ev_periodic *w) 1000void DESTROY (ev_periodic *w)
907 CODE: 1001 CODE:
911void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef) 1005void set (ev_periodic *w, NV at, NV interval = 0., SV *reschedule_cb = &PL_sv_undef)
912 INIT: 1006 INIT:
913 CHECK_REPEAT (interval); 1007 CHECK_REPEAT (interval);
914 CODE: 1008 CODE:
915{ 1009{
916 SvREFCNT_dec (w->fh); 1010 SvREFCNT_dec (e_fh (w));
917 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1011 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
918 1012
919 RESET (periodic, w, (w, at, interval, w->fh ? e_periodic_cb : 0)); 1013 RESET (periodic, w, (w, at, interval, e_fh (w) ? e_periodic_cb : 0));
920} 1014}
921 1015
922NV at (ev_periodic *w) 1016NV at (ev_periodic *w)
923 CODE: 1017 CODE:
924 RETVAL = w->at; 1018 RETVAL = ev_periodic_at (w);
925 OUTPUT: 1019 OUTPUT:
926 RETVAL 1020 RETVAL
927 1021
928MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_ 1022MODULE = EV PACKAGE = EV::Idle PREFIX = ev_idle_
929 1023
1031 e_destroy (w); 1125 e_destroy (w);
1032 1126
1033void set (ev_stat *w, SV *path, NV interval) 1127void set (ev_stat *w, SV *path, NV interval)
1034 CODE: 1128 CODE:
1035{ 1129{
1036 sv_setsv (w->fh, path); 1130 sv_setsv (e_fh (w), path);
1037 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), interval)); 1131 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), interval));
1038} 1132}
1039 1133
1040SV *path (ev_stat *w, SV *new_path = 0) 1134SV *path (ev_stat *w, SV *new_path = 0)
1041 CODE: 1135 CODE:
1042{ 1136{
1043 RETVAL = SvREFCNT_inc (w->fh); 1137 RETVAL = SvREFCNT_inc (e_fh (w));
1044 1138
1045 if (items > 1) 1139 if (items > 1)
1046 { 1140 {
1047 SvREFCNT_dec (w->fh); 1141 SvREFCNT_dec (e_fh (w));
1048 w->fh = newSVsv (new_path); 1142 e_fh (w) = newSVsv (new_path);
1049 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), w->interval)); 1143 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), w->interval));
1050 } 1144 }
1051} 1145}
1052 OUTPUT: 1146 OUTPUT:
1053 RETVAL 1147 RETVAL
1054 1148
1056 CODE: 1150 CODE:
1057{ 1151{
1058 RETVAL = w->interval; 1152 RETVAL = w->interval;
1059 1153
1060 if (items > 1) 1154 if (items > 1)
1061 RESET (stat, w, (w, SvPVbyte_nolen (w->fh), new_interval)); 1155 RESET (stat, w, (w, SvPVbyte_nolen (e_fh (w)), new_interval));
1062} 1156}
1063 OUTPUT: 1157 OUTPUT:
1064 RETVAL 1158 RETVAL
1065 1159
1066void prev (ev_stat *w) 1160void prev (ev_stat *w)
1125 e_destroy (w); 1219 e_destroy (w);
1126 1220
1127void set (ev_embed *w, struct ev_loop *loop) 1221void set (ev_embed *w, struct ev_loop *loop)
1128 CODE: 1222 CODE:
1129{ 1223{
1130 sv_setsv (w->fh, ST (1)); 1224 sv_setsv (e_fh (w), ST (1));
1131 RESET (embed, w, (w, loop)); 1225 RESET (embed, w, (w, loop));
1132} 1226}
1133 1227
1134SV *other (ev_embed *w) 1228SV *other (ev_embed *w)
1135 CODE: 1229 CODE:
1136 RETVAL = newSVsv (w->fh); 1230 RETVAL = newSVsv (e_fh (w));
1231 OUTPUT:
1232 RETVAL
1233
1234void ev_embed_sweep (ev_embed *w)
1235 C_ARGS: e_loop (w), w
1236
1237MODULE = EV PACKAGE = EV::Async PREFIX = ev_async_
1238
1239void ev_async_start (ev_async *w)
1240 CODE:
1241 START (async, w);
1242
1243void ev_async_stop (ev_async *w)
1244 CODE:
1245 STOP (async, w);
1246
1247void DESTROY (ev_async *w)
1248 CODE:
1249 STOP (async, w);
1250 e_destroy (w);
1251
1252void ev_async_send (ev_async *w)
1253 C_ARGS: e_loop (w), w
1254
1255SV *ev_async_async_pending (ev_async *w)
1256 CODE:
1257 RETVAL = boolSV (ev_async_pending (w));
1137 OUTPUT: 1258 OUTPUT:
1138 RETVAL 1259 RETVAL
1139 1260
1140MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ 1261MODULE = EV PACKAGE = EV::Loop PREFIX = ev_
1141 1262
1157 if (loop != evapi.default_loop) /* global destruction sucks */ 1278 if (loop != evapi.default_loop) /* global destruction sucks */
1158 ev_loop_destroy (loop); 1279 ev_loop_destroy (loop);
1159 1280
1160void ev_loop_fork (struct ev_loop *loop) 1281void ev_loop_fork (struct ev_loop *loop)
1161 1282
1283void ev_verify (struct ev_loop *loop)
1284
1162NV ev_now (struct ev_loop *loop) 1285NV ev_now (struct ev_loop *loop)
1163 1286
1287void ev_now_update (struct ev_loop *loop)
1288
1289void ev_suspend (struct ev_loop *loop)
1290
1291void ev_resume (struct ev_loop *loop)
1292
1164void ev_set_io_collect_interval (struct ev_loop *loop, NV interval) 1293void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1165 1294
1166void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval) 1295void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1167 1296
1168unsigned int ev_backend (struct ev_loop *loop) 1297unsigned int ev_backend (struct ev_loop *loop)
1169 1298
1170unsigned int ev_loop_count (struct ev_loop *loop) 1299unsigned int ev_iteration (struct ev_loop *loop)
1300
1301unsigned int ev_depth (struct ev_loop *loop)
1171 1302
1172void ev_loop (struct ev_loop *loop, int flags = 0) 1303void ev_loop (struct ev_loop *loop, int flags = 0)
1173 1304
1174void ev_unloop (struct ev_loop *loop, int how = 1) 1305void ev_unloop (struct ev_loop *loop, int how = 1)
1175 1306
1176void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) 1307void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1177 1308
1309unsigned int ev_pending_count (struct ev_loop *loop)
1310
1311void ev_invoke_pending (struct ev_loop *loop)
1312
1178#if 0 1313#if 0
1179 1314
1180void ev_feed_signal_event (struct ev_loop *loop, SV *signal) 1315void ev_feed_signal_event (struct ev_loop *loop, SV *signal)
1181 CODE: 1316 CODE:
1182{ 1317{
1183 Signal signum = sv_signum (signal); 1318 Signal signum = s_signum (signal);
1184 CHECK_SIG (signal, signum); 1319 CHECK_SIG (signal, signum);
1185 1320
1186 ev_feed_signal_event (loop, signum); 1321 ev_feed_signal_event (loop, signum);
1187} 1322}
1188 1323
1191ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb) 1326ev_io *io (struct ev_loop *loop, SV *fh, int events, SV *cb)
1192 ALIAS: 1327 ALIAS:
1193 io_ns = 1 1328 io_ns = 1
1194 CODE: 1329 CODE:
1195{ 1330{
1196 int fd = sv_fileno (fh); 1331 int fd = s_fileno (fh, events & EV_WRITE);
1197 CHECK_FD (fh, fd); 1332 CHECK_FD (fh, fd);
1198 1333
1199 RETVAL = e_new (sizeof (ev_io), cb, ST (0)); 1334 RETVAL = e_new (sizeof (ev_io), cb, ST (0));
1200 RETVAL->fh = newSVsv (fh); 1335 e_fh (RETVAL) = newSVsv (fh);
1201 ev_io_set (RETVAL, fd, events); 1336 ev_io_set (RETVAL, fd, events);
1202 if (!ix) START (io, RETVAL); 1337 if (!ix) START (io, RETVAL);
1203} 1338}
1204 OUTPUT: 1339 OUTPUT:
1205 RETVAL 1340 RETVAL
1223 CHECK_REPEAT (interval); 1358 CHECK_REPEAT (interval);
1224 CODE: 1359 CODE:
1225{ 1360{
1226 ev_periodic *w; 1361 ev_periodic *w;
1227 w = e_new (sizeof (ev_periodic), cb, ST (0)); 1362 w = e_new (sizeof (ev_periodic), cb, ST (0));
1228 w->fh = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0; 1363 e_fh (w) = SvTRUE (reschedule_cb) ? newSVsv (reschedule_cb) : 0;
1229 ev_periodic_set (w, at, interval, w->fh ? e_periodic_cb : 0); 1364 ev_periodic_set (w, at, interval, e_fh (w) ? e_periodic_cb : 0);
1230 RETVAL = e_bless ((ev_watcher *)w, stash_periodic); 1365 RETVAL = e_bless ((ev_watcher *)w, stash_periodic);
1231 if (!ix) START (periodic, w); 1366 if (!ix) START (periodic, w);
1232} 1367}
1233 OUTPUT: 1368 OUTPUT:
1234 RETVAL 1369 RETVAL
1235 1370
1236#if 0
1237
1238ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb) 1371ev_signal *signal (struct ev_loop *loop, SV *signal, SV *cb)
1239 ALIAS: 1372 ALIAS:
1240 signal_ns = 1 1373 signal_ns = 1
1241 CODE: 1374 CODE:
1242{ 1375{
1243 Signal signum = sv_signum (signal); 1376 Signal signum = s_signum (signal);
1244 CHECK_SIG (signal, signum); 1377 CHECK_SIG (signal, signum);
1245 1378
1246 RETVAL = e_new (sizeof (ev_signal), cb, ST (0)); 1379 RETVAL = e_new (sizeof (ev_signal), cb, ST (0));
1247 ev_signal_set (RETVAL, signum); 1380 ev_signal_set (RETVAL, signum);
1248 if (!ix) START (signal, RETVAL); 1381 if (!ix) START_SIGNAL (RETVAL);
1249} 1382}
1250 OUTPUT: 1383 OUTPUT:
1251 RETVAL 1384 RETVAL
1252
1253#endif
1254 1385
1255ev_idle *idle (struct ev_loop *loop, SV *cb) 1386ev_idle *idle (struct ev_loop *loop, SV *cb)
1256 ALIAS: 1387 ALIAS:
1257 idle_ns = 1 1388 idle_ns = 1
1258 CODE: 1389 CODE:
1305ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) 1436ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1306 ALIAS: 1437 ALIAS:
1307 stat_ns = 1 1438 stat_ns = 1
1308 CODE: 1439 CODE:
1309 RETVAL = e_new (sizeof (ev_stat), cb, ST (0)); 1440 RETVAL = e_new (sizeof (ev_stat), cb, ST (0));
1310 RETVAL->fh = newSVsv (path); 1441 e_fh (RETVAL) = newSVsv (path);
1311 ev_stat_set (RETVAL, SvPVbyte_nolen (RETVAL->fh), interval); 1442 ev_stat_set (RETVAL, SvPVbyte_nolen (e_fh (RETVAL)), interval);
1312 if (!ix) START (stat, RETVAL); 1443 if (!ix) START (stat, RETVAL);
1313 OUTPUT: 1444 OUTPUT:
1314 RETVAL 1445 RETVAL
1315 1446
1316ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = &PL_sv_undef) 1447ev_embed *embed (struct ev_loop *loop, struct ev_loop *other, SV *cb = 0)
1317 ALIAS: 1448 ALIAS:
1318 embed_ns = 1 1449 embed_ns = 1
1319 CODE: 1450 CODE:
1320{ 1451{
1321 if (!(ev_backend (other) & ev_embeddable_backends ())) 1452 if (!(ev_backend (other) & ev_embeddable_backends ()))
1322 croak ("passed loop is not embeddable via EV::embed,"); 1453 croak ("passed loop is not embeddable via EV::embed,");
1323 1454
1324 RETVAL = e_new (sizeof (ev_embed), cb, ST (0)); 1455 RETVAL = e_new (sizeof (ev_embed), cb, ST (0));
1325 RETVAL->fh = newSVsv (ST (1)); 1456 e_fh (RETVAL) = newSVsv (ST (1));
1326 ev_embed_set (RETVAL, other); 1457 ev_embed_set (RETVAL, other);
1327
1328 if (!SvOK (cb)) ev_set_cb (RETVAL, 0);
1329
1330 if (!ix) START (embed, RETVAL); 1458 if (!ix) START (embed, RETVAL);
1331} 1459}
1460 OUTPUT:
1461 RETVAL
1462
1463ev_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);
1332 OUTPUT: 1470 OUTPUT:
1333 RETVAL 1471 RETVAL
1334 1472
1335void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb) 1473void once (struct ev_loop *loop, SV *fh, int events, SV *timeout, SV *cb)
1336 CODE: 1474 CODE:
1337 ev_once ( 1475 ev_once (
1338 loop, 1476 loop,
1339 sv_fileno (fh), events, 1477 s_fileno (fh, events & EV_WRITE), events,
1340 SvOK (timeout) ? SvNV (timeout) : -1., 1478 SvOK (timeout) ? SvNV (timeout) : -1.,
1341 e_once_cb, 1479 e_once_cb,
1342 newSVsv (cb) 1480 newSVsv (cb)
1343 ); 1481 );
1344 1482

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines