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

Comparing EV/EV.xs (file contents):
Revision 1.2 by root, Fri Oct 26 16:51:27 2007 UTC vs.
Revision 1.4 by root, Fri Oct 26 18:21:32 2007 UTC

7 7
8#include <sys/time.h> 8#include <sys/time.h>
9#include <time.h> 9#include <time.h>
10#include <event.h> 10#include <event.h>
11#include <evdns.h> 11#include <evdns.h>
12/*include <evhttp.h>*/ /* does not compile */ 12
13/* workaround for evhttp.h requiring obscure bsd headers */
14#ifndef TAILQ_ENTRY
15#define TAILQ_ENTRY(type) \
16struct { \
17 struct type *tqe_next; /* next element */ \
18 struct type **tqe_prev; /* address of previous next element */ \
19}
20#endif /* !TAILQ_ENTRY */
21#include <evhttp.h>
13 22
14#define EV_NONE 0 23#define EV_NONE 0
15#define EV_UNDEF -1 24#define EV_UNDEF -1
16 25
17#define TIMEOUT_NONE HUGE_VAL 26#define TIMEOUT_NONE HUGE_VAL
56 65
57static void e_cb (int fd, short events, void *arg); 66static void e_cb (int fd, short events, void *arg);
58 67
59static int sv_fileno (SV *fh) 68static int sv_fileno (SV *fh)
60{ 69{
61 if (fh)
62 {
63 SvGETMAGIC (fh); 70 SvGETMAGIC (fh);
64 71
65 if (SvROK (fh)) 72 if (SvROK (fh))
66 fh = SvRV (fh); 73 fh = SvRV (fh);
67 74
68 if (SvTYPE (fh) == SVt_PVGV) 75 if (SvTYPE (fh) == SVt_PVGV)
69 return PerlIO_fileno (IoIFP (sv_2io (fh))); 76 return PerlIO_fileno (IoIFP (sv_2io (fh)));
70 77
71 if (SvIOK (fh)) 78 if (SvIOK (fh))
72 return SvIV (fh); 79 return SvIV (fh);
73 }
74 80
75 return -1; 81 return -1;
76} 82}
77 83
78static Event 84static Event
283 289
284int event_dispatch () 290int event_dispatch ()
285 291
286int event_loop (int flags = 0) 292int event_loop (int flags = 0)
287 293
288int event_loopexit (double after) 294int event_loopexit (double after = 0)
289 CODE: 295 CODE:
290{ 296{
291 struct timeval tv; 297 struct timeval tv;
292 tv_set (&tv, after); 298 tv_set (&tv, after);
293 event_loopexit (&tv); 299 event_loopexit (&tv);
294} 300}
295 301
296Event event (SV *cb) 302Event event (SV *cb)
297 CODE: 303 CODE:
298 RETVAL = e_new (0, 0, cb); 304 RETVAL = e_new (NEWSV (0, 0), 0, cb);
299 OUTPUT: 305 OUTPUT:
300 RETVAL 306 RETVAL
301 307
302Event io (SV *fh, short events, SV *cb) 308Event io (SV *fh, short events, SV *cb)
303 ALIAS: 309 ALIAS:
310 316
311Event timer (double after, int repeat, SV *cb) 317Event timer (double after, int repeat, SV *cb)
312 ALIAS: 318 ALIAS:
313 timer_ns = 1 319 timer_ns = 1
314 CODE: 320 CODE:
315 RETVAL = e_new (0, 0, cb); 321 RETVAL = e_new (NEWSV (0, 0), 0, cb);
316 RETVAL->timeout = after; 322 RETVAL->timeout = after;
317 RETVAL->interval = repeat; 323 RETVAL->interval = repeat;
318 if (!ix) e_start (RETVAL); 324 if (!ix) e_start (RETVAL);
319 OUTPUT: 325 OUTPUT:
320 RETVAL 326 RETVAL
321 327
322Event timer_abs (double at, double interval, SV *cb) 328Event timer_abs (double at, double interval, SV *cb)
323 ALIAS: 329 ALIAS:
324 timer_abs_ns = 1 330 timer_abs_ns = 1
325 CODE: 331 CODE:
326 RETVAL = e_new (0, 0, cb); 332 RETVAL = e_new (NEWSV (0, 0), 0, cb);
327 RETVAL->timeout = at; 333 RETVAL->timeout = at;
328 RETVAL->interval = interval; 334 RETVAL->interval = interval;
329 RETVAL->abstime = 1; 335 RETVAL->abstime = 1;
330 if (!ix) e_start (RETVAL); 336 if (!ix) e_start (RETVAL);
331 OUTPUT: 337 OUTPUT:
405 CODE: 411 CODE:
406 e_stop (ev); 412 e_stop (ev);
407 SvREFCNT_dec (ev->cb); 413 SvREFCNT_dec (ev->cb);
408 SvREFCNT_dec (ev->fh); 414 SvREFCNT_dec (ev->fh);
409 415
410void cb (Event ev, SV *new_cb) 416SV *cb (Event ev, SV *new_cb = 0)
411 CODE: 417 CODE:
418 RETVAL = newSVsv (ev->cb);
419 if (items > 1)
412 sv_setsv (ev->cb, new_cb); 420 sv_setsv (ev->cb, new_cb);
421 OUTPUT:
422 RETVAL
413 423
414SV *fh (Event ev, SV *new_fh = 0) 424SV *fh (Event ev, SV *new_fh = 0)
415 ALIAS: 425 ALIAS:
416 signal = 0 426 signal = 0
417 CODE: 427 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines