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

Comparing EV/EV.xs (file contents):
Revision 1.138 by root, Wed Apr 14 00:17:22 2010 UTC vs.
Revision 1.144 by root, Sun Oct 24 17:58:41 2010 UTC

29# define fd_mask Perl_fd_mask 29# define fd_mask Perl_fd_mask
30#endif 30#endif
31/* due to bugs in OS X we have to use libev/ explicitly here */ 31/* due to bugs in OS X we have to use libev/ explicitly here */
32#include "libev/ev.c" 32#include "libev/ev.c"
33 33
34#ifndef _WIN32 34#if !defined(_WIN32) && !defined(_MINIX)
35# include <pthread.h> 35# include <pthread.h>
36#endif 36#endif
37 37
38#define e_loop(w) INT2PTR (struct ev_loop *, SvIVX (((ev_watcher *)(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 39#define e_flags(w) ((ev_watcher *)(w))->e_flags
364 const_iv (EV_, UNDEF) 364 const_iv (EV_, UNDEF)
365 const_iv (EV_, NONE) 365 const_iv (EV_, NONE)
366 const_iv (EV_, READ) 366 const_iv (EV_, READ)
367 const_iv (EV_, WRITE) 367 const_iv (EV_, WRITE)
368 const_iv (EV_, IO) 368 const_iv (EV_, IO)
369 const_iv (EV_, TIMEOUT) /* deprecated */
370 const_iv (EV_, TIMER) 369 const_iv (EV_, TIMEOUT)
371 const_iv (EV_, PERIODIC) 370 const_iv (EV_, PERIODIC)
372 const_iv (EV_, SIGNAL) 371 const_iv (EV_, SIGNAL)
373 const_iv (EV_, CHILD) 372 const_iv (EV_, CHILD)
374 const_iv (EV_, STAT) 373 const_iv (EV_, STAT)
375 const_iv (EV_, IDLE) 374 const_iv (EV_, IDLE)
379 const_iv (EV_, FORK) 378 const_iv (EV_, FORK)
380 const_iv (EV_, ASYNC) 379 const_iv (EV_, ASYNC)
381 const_iv (EV_, CUSTOM) 380 const_iv (EV_, CUSTOM)
382 const_iv (EV_, ERROR) 381 const_iv (EV_, ERROR)
383 382
384 const_iv (EV, LOOP_NONBLOCK)
385 const_iv (EV, LOOP_ONESHOT)
386
387 const_iv (EV, UNLOOP_CANCEL) 383 const_iv (EV, RUN_NOWAIT)
388 const_iv (EV, UNLOOP_ONE) 384 const_iv (EV, RUN_ONCE)
385
386 const_iv (EV, BREAK_CANCEL)
387 const_iv (EV, BREAK_ONE)
389 const_iv (EV, UNLOOP_ALL) 388 const_iv (EV, BREAK_ALL)
390
391 const_iv (EV, BACKEND_SELECT) 389 const_iv (EV, BACKEND_SELECT)
392 const_iv (EV, BACKEND_POLL) 390 const_iv (EV, BACKEND_POLL)
393 const_iv (EV, BACKEND_EPOLL) 391 const_iv (EV, BACKEND_EPOLL)
394 const_iv (EV, BACKEND_KQUEUE) 392 const_iv (EV, BACKEND_KQUEUE)
395 const_iv (EV, BACKEND_DEVPOLL) 393 const_iv (EV, BACKEND_DEVPOLL)
402 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ 400 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
403 const_iv (EV, FLAG_NOINOTIFY) 401 const_iv (EV, FLAG_NOINOTIFY)
404 402
405 const_iv (EV_, VERSION_MAJOR) 403 const_iv (EV_, VERSION_MAJOR)
406 const_iv (EV_, VERSION_MINOR) 404 const_iv (EV_, VERSION_MINOR)
405#if EV_COMPAT3
406 const_iv (EV_, TIMER)
407
408 const_iv (EV, LOOP_NONBLOCK)
409 const_iv (EV, LOOP_ONESHOT)
410
411 const_iv (EV, UNLOOP_CANCEL)
412 const_iv (EV, UNLOOP_ONE)
413 const_iv (EV, UNLOOP_ALL)
414#endif
407 }; 415 };
408 416
409 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 417 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
410 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 418 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
411 419
448 evapi.now = ev_now; 456 evapi.now = ev_now;
449 evapi.now_update = ev_now_update; 457 evapi.now_update = ev_now_update;
450 evapi.suspend = ev_suspend; 458 evapi.suspend = ev_suspend;
451 evapi.resume = ev_resume; 459 evapi.resume = ev_resume;
452 evapi.backend = ev_backend; 460 evapi.backend = ev_backend;
453 evapi.unloop = ev_unloop; 461 evapi.break_ = ev_break;
454 evapi.invoke_pending = ev_invoke_pending; 462 evapi.invoke_pending = ev_invoke_pending;
455 evapi.pending_count = ev_pending_count; 463 evapi.pending_count = ev_pending_count;
456 evapi.verify = ev_verify; 464 evapi.verify = ev_verify;
457 evapi.set_loop_release_cb = ev_set_loop_release_cb; 465 evapi.set_loop_release_cb = ev_set_loop_release_cb;
458 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; 466 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb;
459 evapi.ref = ev_ref; 467 evapi.ref = ev_ref;
460 evapi.unref = ev_unref; 468 evapi.unref = ev_unref;
461 evapi.loop = ev_loop; 469 evapi.run = ev_run;
462 evapi.once = ev_once; 470 evapi.once = ev_once;
463 evapi.io_start = ev_io_start; 471 evapi.io_start = ev_io_start;
464 evapi.io_stop = ev_io_stop; 472 evapi.io_stop = ev_io_stop;
465 evapi.timer_start = ev_timer_start; 473 evapi.timer_start = ev_timer_start;
466 evapi.timer_stop = ev_timer_stop; 474 evapi.timer_stop = ev_timer_stop;
474 evapi.idle_stop = ev_idle_stop; 482 evapi.idle_stop = ev_idle_stop;
475 evapi.prepare_start = ev_prepare_start; 483 evapi.prepare_start = ev_prepare_start;
476 evapi.prepare_stop = ev_prepare_stop; 484 evapi.prepare_stop = ev_prepare_stop;
477 evapi.check_start = ev_check_start; 485 evapi.check_start = ev_check_start;
478 evapi.check_stop = ev_check_stop; 486 evapi.check_stop = ev_check_stop;
487#if EV_CHILD_ENABLE
479 evapi.child_start = ev_child_start; 488 evapi.child_start = ev_child_start;
480 evapi.child_stop = ev_child_stop; 489 evapi.child_stop = ev_child_stop;
490#endif
481 evapi.stat_start = ev_stat_start; 491 evapi.stat_start = ev_stat_start;
482 evapi.stat_stop = ev_stat_stop; 492 evapi.stat_stop = ev_stat_stop;
483 evapi.stat_stat = ev_stat_stat; 493 evapi.stat_stat = ev_stat_stat;
484 evapi.embed_start = ev_embed_start; 494 evapi.embed_start = ev_embed_start;
485 evapi.embed_stop = ev_embed_stop; 495 evapi.embed_stop = ev_embed_stop;
493 evapi.invoke = ev_invoke; 503 evapi.invoke = ev_invoke;
494 504
495 sv_setiv (sv, (IV)&evapi); 505 sv_setiv (sv, (IV)&evapi);
496 SvREADONLY_on (sv); 506 SvREADONLY_on (sv);
497 } 507 }
498#ifndef _WIN32 508#if !defined(_WIN32) && !defined(_MINIX)
499 pthread_atfork (0, 0, ev_default_fork); 509 pthread_atfork (0, 0, ev_default_fork);
500#endif 510#endif
501} 511}
502 512
503SV *ev_default_loop (unsigned int flags = 0) 513SV *ev_default_loop (unsigned int flags = 0)
518 OUTPUT: 528 OUTPUT:
519 RETVAL 529 RETVAL
520 530
521void ev_default_destroy () 531void ev_default_destroy ()
522 CODE: 532 CODE:
523 ev_default_destroy (); 533 ev_loop_destroy (EV_DEFAULT_UC);
524 SvREFCNT_dec (default_loop_sv); 534 SvREFCNT_dec (default_loop_sv);
525 default_loop_sv = 0; 535 default_loop_sv = 0;
526 536
527unsigned int ev_supported_backends () 537unsigned int ev_supported_backends ()
528 538
548 558
549unsigned int ev_backend () 559unsigned int ev_backend ()
550 C_ARGS: evapi.default_loop 560 C_ARGS: evapi.default_loop
551 561
552void ev_verify () 562void ev_verify ()
563 ALIAS:
564 loop_verify = 1
553 C_ARGS: evapi.default_loop 565 C_ARGS: evapi.default_loop
554 566
555unsigned int ev_iteration () 567unsigned int ev_iteration ()
568 ALIAS:
569 loop_count = 1
556 C_ARGS: evapi.default_loop 570 C_ARGS: evapi.default_loop
557 571
558unsigned int ev_depth () 572unsigned int ev_depth ()
573 ALIAS:
574 loop_depth = 1
559 C_ARGS: evapi.default_loop 575 C_ARGS: evapi.default_loop
560 576
561void ev_set_io_collect_interval (NV interval) 577void ev_set_io_collect_interval (NV interval)
562 C_ARGS: evapi.default_loop, interval 578 C_ARGS: evapi.default_loop, interval
563 579
564void ev_set_timeout_collect_interval (NV interval) 580void ev_set_timeout_collect_interval (NV interval)
565 C_ARGS: evapi.default_loop, interval 581 C_ARGS: evapi.default_loop, interval
566 582
567void ev_loop (int flags = 0) 583void ev_run (int flags = 0)
584 ALIAS:
585 loop = 1
568 C_ARGS: evapi.default_loop, flags 586 C_ARGS: evapi.default_loop, flags
569 587
570void ev_unloop (int how = EVUNLOOP_ONE) 588void ev_break (int how = EVBREAK_ONE)
589 ALIAS:
590 unloop = 1
571 C_ARGS: evapi.default_loop, how 591 C_ARGS: evapi.default_loop, how
572 592
573void ev_feed_fd_event (int fd, int revents = EV_NONE) 593void ev_feed_fd_event (int fd, int revents = EV_NONE)
574 C_ARGS: evapi.default_loop, fd, revents 594 C_ARGS: evapi.default_loop, fd, revents
575 595
693 ev_fork_set (RETVAL); 713 ev_fork_set (RETVAL);
694 if (!ix) START (fork, RETVAL); 714 if (!ix) START (fork, RETVAL);
695 OUTPUT: 715 OUTPUT:
696 RETVAL 716 RETVAL
697 717
718
698ev_child *child (int pid, int trace, SV *cb) 719ev_child *child (int pid, int trace, SV *cb)
699 ALIAS: 720 ALIAS:
700 child_ns = 1 721 child_ns = 1
701 CODE: 722 CODE:
723#if EV_CHILD_ENABLE
702 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); 724 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv);
703 ev_child_set (RETVAL, pid, trace); 725 ev_child_set (RETVAL, pid, trace);
704 if (!ix) START (child, RETVAL); 726 if (!ix) START (child, RETVAL);
727#else
728 croak ("EV::child watchers not supported on this platform");
729#endif
705 OUTPUT: 730 OUTPUT:
706 RETVAL 731 RETVAL
732
707 733
708ev_stat *stat (SV *path, NV interval, SV *cb) 734ev_stat *stat (SV *path, NV interval, SV *cb)
709 ALIAS: 735 ALIAS:
710 stat_ns = 1 736 stat_ns = 1
711 CODE: 737 CODE:
1079 STOP (fork, w); 1105 STOP (fork, w);
1080 e_destroy (w); 1106 e_destroy (w);
1081 1107
1082MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 1108MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
1083 1109
1110#if EV_CHILD_ENABLE
1111
1084void ev_child_start (ev_child *w) 1112void ev_child_start (ev_child *w)
1085 CODE: 1113 CODE:
1086 START (child, w); 1114 START (child, w);
1087 1115
1088void ev_child_stop (ev_child *w) 1116void ev_child_stop (ev_child *w)
1106 RETVAL = ix == 0 ? w->pid 1134 RETVAL = ix == 0 ? w->pid
1107 : ix == 1 ? w->rpid 1135 : ix == 1 ? w->rpid
1108 : w->rstatus; 1136 : w->rstatus;
1109 OUTPUT: 1137 OUTPUT:
1110 RETVAL 1138 RETVAL
1139
1140#endif
1111 1141
1112MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_ 1142MODULE = EV PACKAGE = EV::Stat PREFIX = ev_stat_
1113 1143
1114void ev_stat_start (ev_stat *w) 1144void ev_stat_start (ev_stat *w)
1115 CODE: 1145 CODE:
1273 OUTPUT: 1303 OUTPUT:
1274 RETVAL 1304 RETVAL
1275 1305
1276void DESTROY (struct ev_loop *loop) 1306void DESTROY (struct ev_loop *loop)
1277 CODE: 1307 CODE:
1278 if (loop != evapi.default_loop) /* global destruction sucks */ 1308 /* 1. the default loop shouldn't be freed by destroying it'S pelr loop object */
1309 /* 2. not doing so helps avoid many global destruction bugs in perl, too */
1310 if (loop != evapi.default_loop)
1279 ev_loop_destroy (loop); 1311 ev_loop_destroy (loop);
1280 1312
1281void ev_loop_fork (struct ev_loop *loop) 1313void ev_loop_fork (struct ev_loop *loop)
1282 1314
1315NV ev_now (struct ev_loop *loop)
1316
1317void ev_now_update (struct ev_loop *loop)
1318
1319void ev_suspend (struct ev_loop *loop)
1320
1321void ev_resume (struct ev_loop *loop)
1322
1323void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1324
1325void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1326
1327unsigned int ev_backend (struct ev_loop *loop)
1328
1283void ev_verify (struct ev_loop *loop) 1329void ev_verify (struct ev_loop *loop)
1284 1330 ALIAS:
1285NV ev_now (struct ev_loop *loop) 1331 loop_verify = 1
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
1293void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1294
1295void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1296
1297unsigned int ev_backend (struct ev_loop *loop)
1298 1332
1299unsigned int ev_iteration (struct ev_loop *loop) 1333unsigned int ev_iteration (struct ev_loop *loop)
1334 ALIAS:
1335 loop_count = 1
1300 1336
1301unsigned int ev_depth (struct ev_loop *loop) 1337unsigned int ev_depth (struct ev_loop *loop)
1338 ALIAS:
1339 loop_depth = 1
1302 1340
1303void ev_loop (struct ev_loop *loop, int flags = 0) 1341void ev_run (struct ev_loop *loop, int flags = 0)
1342 ALIAS:
1343 loop = 1
1304 1344
1305void ev_unloop (struct ev_loop *loop, int how = 1) 1345void ev_break (struct ev_loop *loop, int how = 1)
1346 ALIAS:
1347 unloop = 1
1306 1348
1307void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) 1349void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1308 1350
1309unsigned int ev_pending_count (struct ev_loop *loop) 1351unsigned int ev_pending_count (struct ev_loop *loop)
1310 1352
1421 ev_fork_set (RETVAL); 1463 ev_fork_set (RETVAL);
1422 if (!ix) START (fork, RETVAL); 1464 if (!ix) START (fork, RETVAL);
1423 OUTPUT: 1465 OUTPUT:
1424 RETVAL 1466 RETVAL
1425 1467
1468
1426ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) 1469ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1427 ALIAS: 1470 ALIAS:
1428 child_ns = 1 1471 child_ns = 1
1429 CODE: 1472 CODE:
1473#if EV_CHILD_ENABLE
1430 RETVAL = e_new (sizeof (ev_child), cb, ST (0)); 1474 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1431 ev_child_set (RETVAL, pid, trace); 1475 ev_child_set (RETVAL, pid, trace);
1432 if (!ix) START (child, RETVAL); 1476 if (!ix) START (child, RETVAL);
1477#else
1478 croak ("EV::child watchers not supported on this platform");
1479#endif
1433 OUTPUT: 1480 OUTPUT:
1434 RETVAL 1481 RETVAL
1435 1482
1436ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb) 1483ev_stat *stat (struct ev_loop *loop, SV *path, NV interval, SV *cb)
1437 ALIAS: 1484 ALIAS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines