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

Comparing EV/EV.xs (file contents):
Revision 1.73 by root, Fri Nov 23 05:00:44 2007 UTC vs.
Revision 1.77 by root, Fri Nov 23 16:37:37 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;
379 evapi.prepare_stop = ev_prepare_stop; 418 evapi.prepare_stop = ev_prepare_stop;
380 evapi.check_start = ev_check_start; 419 evapi.check_start = ev_check_start;
381 evapi.check_stop = ev_check_stop; 420 evapi.check_stop = ev_check_stop;
382 evapi.child_start = ev_child_start; 421 evapi.child_start = ev_child_start;
383 evapi.child_stop = ev_child_stop; 422 evapi.child_stop = ev_child_stop;
423 evapi.ref = ev_ref;
424 evapi.unref = ev_unref;
384 425
385 sv_setiv (sv, (IV)&evapi); 426 sv_setiv (sv, (IV)&evapi);
386 SvREADONLY_on (sv); 427 SvREADONLY_on (sv);
387 } 428 }
388#ifndef _WIN32 429#ifndef _WIN32
390#endif 431#endif
391} 432}
392 433
393NV ev_now () 434NV ev_now ()
394 435
395int ev_method () 436unsigned int ev_backend ()
396 437
397NV ev_time () 438NV ev_time ()
398 439
399int ev_default_loop (int methods = ev_supported_methods ()) 440unsigned int ev_default_loop (unsigned int flags = ev_supported_backends ())
400 441
401void ev_loop (int flags = 0) 442void ev_loop (int flags = 0)
402 443
403void ev_unloop (int how = 1) 444void ev_unloop (int how = 1)
404 445
495 ev_child_set (RETVAL, pid); 536 ev_child_set (RETVAL, pid);
496 if (!ix) ev_child_start (RETVAL); 537 if (!ix) ev_child_start (RETVAL);
497 OUTPUT: 538 OUTPUT:
498 RETVAL 539 RETVAL
499 540
541void once (SV *fh, int events, SV *timeout, SV *cb)
542 CODE:
543 ev_once (
544 sv_fileno (fh), events,
545 SvOK (timeout) ? SvNV (timeout) : -1.,
546 e_once_cb,
547 newSVsv (cb)
548 );
500 549
501PROTOTYPES: DISABLE 550PROTOTYPES: DISABLE
502 551
503MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_ 552MODULE = EV PACKAGE = EV::Watcher PREFIX = ev_
504 553

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines