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

Comparing EV/EV.xs (file contents):
Revision 1.72 by root, Thu Nov 22 12:28:27 2007 UTC vs.
Revision 1.76 by root, Fri Nov 23 13:08:56 2007 UTC

89 fh = SvRV (fh); 89 fh = SvRV (fh);
90 90
91 if (SvTYPE (fh) == SVt_PVGV) 91 if (SvTYPE (fh) == SVt_PVGV)
92 return PerlIO_fileno (IoIFP (sv_2io (fh))); 92 return PerlIO_fileno (IoIFP (sv_2io (fh)));
93 93
94 if ((SvIV (fh) >= 0) && (SvIV (fh) < 0x7ffffff)) 94 if (SvOK (fh) && (SvIV (fh) >= 0) && (SvIV (fh) < 0x7fffffffL))
95 return SvIV (fh); 95 return SvIV (fh);
96 96
97 return -1; 97 return -1;
98} 98}
99 99
142 } 142 }
143 143
144 return rv; 144 return rv;
145} 145}
146 146
147static SV *sv_events_cache;
148
147static void 149static void
148e_cb (struct ev_watcher *w, int revents) 150e_cb (struct ev_watcher *w, int revents)
149{ 151{
150 dSP; 152 dSP;
151 I32 mark = SP - PL_stack_base; 153 I32 mark = SP - PL_stack_base;
152 SV *sv_self, *sv_events, *sv_status = 0; 154 SV *sv_self, *sv_events;
153 static SV *sv_events_cache;
154 155
155 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ 156 sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */
156 157
157 if (sv_events_cache) 158 if (sv_events_cache)
158 { 159 {
169 170
170 PUTBACK; 171 PUTBACK;
171 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); 172 call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL);
172 173
173 SvREFCNT_dec (sv_self); 174 SvREFCNT_dec (sv_self);
175
176 if (sv_events_cache)
174 SvREFCNT_dec (sv_status); 177 SvREFCNT_dec (sv_events);
178 else
179 sv_events_cache = sv_events;
180
181 if (SvTRUE (ERRSV))
182 {
183 PUSHMARK (SP);
184 PUTBACK;
185 call_sv (get_sv ("EV::DIED", 1), G_DISCARD | G_VOID | G_EVAL | G_KEEPERR);
186 }
187
188 SP = PL_stack_base + mark;
189 PUTBACK;
190}
191
192static void
193e_once_cb (int revents, void *arg)
194{
195 dSP;
196 I32 mark = SP - PL_stack_base;
197 SV *sv_events;
198
199 if (sv_events_cache)
200 {
201 sv_events = sv_events_cache; sv_events_cache = 0;
202 SvIV_set (sv_events, revents);
203 }
204 else
205 sv_events = newSViv (revents);
206
207 PUSHMARK (SP);
208 XPUSHs (sv_events);
209
210 PUTBACK;
211 call_sv ((SV *)arg, G_DISCARD | G_VOID | G_EVAL);
212
213 SvREFCNT_dec ((SV *)arg);
175 214
176 if (sv_events_cache) 215 if (sv_events_cache)
177 SvREFCNT_dec (sv_events); 216 SvREFCNT_dec (sv_events);
178 else 217 else
179 sv_events_cache = sv_events; 218 sv_events_cache = sv_events;
324 const_iv (EV, LOOP_ONESHOT) 363 const_iv (EV, LOOP_ONESHOT)
325 const_iv (EV, LOOP_NONBLOCK) 364 const_iv (EV, LOOP_NONBLOCK)
326 const_iv (EV, UNLOOP_ONE) 365 const_iv (EV, UNLOOP_ONE)
327 const_iv (EV, UNLOOP_ALL) 366 const_iv (EV, UNLOOP_ALL)
328 367
329 const_iv (EV, METHOD_SELECT) 368 const_iv (EV, BACKEND_SELECT)
330 const_iv (EV, METHOD_POLL) 369 const_iv (EV, BACKEND_POLL)
331 const_iv (EV, METHOD_EPOLL) 370 const_iv (EV, BACKEND_EPOLL)
332 const_iv (EV, METHOD_KQUEUE) 371 const_iv (EV, BACKEND_KQUEUE)
333 const_iv (EV, METHOD_DEVPOLL) 372 const_iv (EV, BACKEND_DEVPOLL)
334 const_iv (EV, METHOD_PORT) 373 const_iv (EV, BACKEND_PORT)
335 const_iv (EV, FLAG_AUTO) 374 const_iv (EV, FLAG_AUTO)
336 const_iv (EV, FLAG_NOENV) 375 const_iv (EV, FLAG_NOENV)
337 }; 376 };
338 377
339 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 378 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
357 evapi.ver = EV_API_VERSION; 396 evapi.ver = EV_API_VERSION;
358 evapi.rev = EV_API_REVISION; 397 evapi.rev = EV_API_REVISION;
359 evapi.sv_fileno = sv_fileno; 398 evapi.sv_fileno = sv_fileno;
360 evapi.sv_signum = sv_signum; 399 evapi.sv_signum = sv_signum;
361 evapi.now = ev_now; 400 evapi.now = ev_now;
362 evapi.method = ev_method; 401 evapi.backend = ev_backend;
363 evapi.unloop = ev_unloop; 402 evapi.unloop = ev_unloop;
364 evapi.time = ev_time; 403 evapi.time = ev_time;
365 evapi.loop = ev_loop; 404 evapi.loop = ev_loop;
366 evapi.once = ev_once; 405 evapi.once = ev_once;
367 evapi.io_start = ev_io_start; 406 evapi.io_start = ev_io_start;
390#endif 429#endif
391} 430}
392 431
393NV ev_now () 432NV ev_now ()
394 433
395int ev_method () 434unsigned int ev_backend ()
396 435
397NV ev_time () 436NV ev_time ()
398 437
399int ev_default_loop (int methods = EVMETHOD_ALL) 438unsigned int ev_default_loop (unsigned int flags = ev_supported_backends ())
400 439
401void ev_loop (int flags = 0) 440void ev_loop (int flags = 0)
402 441
403void ev_unloop (int how = 1) 442void ev_unloop (int how = 1)
404 443
495 ev_child_set (RETVAL, pid); 534 ev_child_set (RETVAL, pid);
496 if (!ix) ev_child_start (RETVAL); 535 if (!ix) ev_child_start (RETVAL);
497 OUTPUT: 536 OUTPUT:
498 RETVAL 537 RETVAL
499 538
539void once (SV *fh, int events, SV *timeout, SV *cb)
540 CODE:
541 ev_once (
542 sv_fileno (fh), events,
543 SvOK (timeout) ? SvNV (timeout) : -1.,
544 e_once_cb,
545 newSVsv (cb)
546 );
500 547
501PROTOTYPES: DISABLE 548PROTOTYPES: DISABLE
502 549
503MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ 550MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_
504 551

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines