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

Comparing EV/EV.xs (file contents):
Revision 1.139 by root, Thu Apr 22 11:12:06 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;
495 evapi.invoke = ev_invoke; 503 evapi.invoke = ev_invoke;
496 504
497 sv_setiv (sv, (IV)&evapi); 505 sv_setiv (sv, (IV)&evapi);
498 SvREADONLY_on (sv); 506 SvREADONLY_on (sv);
499 } 507 }
500#ifndef _WIN32 508#if !defined(_WIN32) && !defined(_MINIX)
501 pthread_atfork (0, 0, ev_default_fork); 509 pthread_atfork (0, 0, ev_default_fork);
502#endif 510#endif
503} 511}
504 512
505SV *ev_default_loop (unsigned int flags = 0) 513SV *ev_default_loop (unsigned int flags = 0)
520 OUTPUT: 528 OUTPUT:
521 RETVAL 529 RETVAL
522 530
523void ev_default_destroy () 531void ev_default_destroy ()
524 CODE: 532 CODE:
525 ev_default_destroy (); 533 ev_loop_destroy (EV_DEFAULT_UC);
526 SvREFCNT_dec (default_loop_sv); 534 SvREFCNT_dec (default_loop_sv);
527 default_loop_sv = 0; 535 default_loop_sv = 0;
528 536
529unsigned int ev_supported_backends () 537unsigned int ev_supported_backends ()
530 538
550 558
551unsigned int ev_backend () 559unsigned int ev_backend ()
552 C_ARGS: evapi.default_loop 560 C_ARGS: evapi.default_loop
553 561
554void ev_verify () 562void ev_verify ()
563 ALIAS:
564 loop_verify = 1
555 C_ARGS: evapi.default_loop 565 C_ARGS: evapi.default_loop
556 566
557unsigned int ev_iteration () 567unsigned int ev_iteration ()
568 ALIAS:
569 loop_count = 1
558 C_ARGS: evapi.default_loop 570 C_ARGS: evapi.default_loop
559 571
560unsigned int ev_depth () 572unsigned int ev_depth ()
573 ALIAS:
574 loop_depth = 1
561 C_ARGS: evapi.default_loop 575 C_ARGS: evapi.default_loop
562 576
563void ev_set_io_collect_interval (NV interval) 577void ev_set_io_collect_interval (NV interval)
564 C_ARGS: evapi.default_loop, interval 578 C_ARGS: evapi.default_loop, interval
565 579
566void ev_set_timeout_collect_interval (NV interval) 580void ev_set_timeout_collect_interval (NV interval)
567 C_ARGS: evapi.default_loop, interval 581 C_ARGS: evapi.default_loop, interval
568 582
569void ev_loop (int flags = 0) 583void ev_run (int flags = 0)
584 ALIAS:
585 loop = 1
570 C_ARGS: evapi.default_loop, flags 586 C_ARGS: evapi.default_loop, flags
571 587
572void ev_unloop (int how = EVUNLOOP_ONE) 588void ev_break (int how = EVBREAK_ONE)
589 ALIAS:
590 unloop = 1
573 C_ARGS: evapi.default_loop, how 591 C_ARGS: evapi.default_loop, how
574 592
575void ev_feed_fd_event (int fd, int revents = EV_NONE) 593void ev_feed_fd_event (int fd, int revents = EV_NONE)
576 C_ARGS: evapi.default_loop, fd, revents 594 C_ARGS: evapi.default_loop, fd, revents
577 595
695 ev_fork_set (RETVAL); 713 ev_fork_set (RETVAL);
696 if (!ix) START (fork, RETVAL); 714 if (!ix) START (fork, RETVAL);
697 OUTPUT: 715 OUTPUT:
698 RETVAL 716 RETVAL
699 717
718
719ev_child *child (int pid, int trace, SV *cb)
720 ALIAS:
721 child_ns = 1
722 CODE:
700#if EV_CHILD_ENABLE 723#if EV_CHILD_ENABLE
701
702ev_child *child (int pid, int trace, SV *cb)
703 ALIAS:
704 child_ns = 1
705 CODE:
706 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv); 724 RETVAL = e_new (sizeof (ev_child), cb, default_loop_sv);
707 ev_child_set (RETVAL, pid, trace); 725 ev_child_set (RETVAL, pid, trace);
708 if (!ix) START (child, RETVAL); 726 if (!ix) START (child, RETVAL);
709 OUTPUT: 727#else
710 RETVAL 728 croak ("EV::child watchers not supported on this platform");
711
712#endif 729#endif
730 OUTPUT:
731 RETVAL
732
713 733
714ev_stat *stat (SV *path, NV interval, SV *cb) 734ev_stat *stat (SV *path, NV interval, SV *cb)
715 ALIAS: 735 ALIAS:
716 stat_ns = 1 736 stat_ns = 1
717 CODE: 737 CODE:
1283 OUTPUT: 1303 OUTPUT:
1284 RETVAL 1304 RETVAL
1285 1305
1286void DESTROY (struct ev_loop *loop) 1306void DESTROY (struct ev_loop *loop)
1287 CODE: 1307 CODE:
1288 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)
1289 ev_loop_destroy (loop); 1311 ev_loop_destroy (loop);
1290 1312
1291void ev_loop_fork (struct ev_loop *loop) 1313void ev_loop_fork (struct ev_loop *loop)
1292 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
1293void ev_verify (struct ev_loop *loop) 1329void ev_verify (struct ev_loop *loop)
1294 1330 ALIAS:
1295NV ev_now (struct ev_loop *loop) 1331 loop_verify = 1
1296
1297void ev_now_update (struct ev_loop *loop)
1298
1299void ev_suspend (struct ev_loop *loop)
1300
1301void ev_resume (struct ev_loop *loop)
1302
1303void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1304
1305void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1306
1307unsigned int ev_backend (struct ev_loop *loop)
1308 1332
1309unsigned int ev_iteration (struct ev_loop *loop) 1333unsigned int ev_iteration (struct ev_loop *loop)
1334 ALIAS:
1335 loop_count = 1
1310 1336
1311unsigned int ev_depth (struct ev_loop *loop) 1337unsigned int ev_depth (struct ev_loop *loop)
1338 ALIAS:
1339 loop_depth = 1
1312 1340
1313void ev_loop (struct ev_loop *loop, int flags = 0) 1341void ev_run (struct ev_loop *loop, int flags = 0)
1342 ALIAS:
1343 loop = 1
1314 1344
1315void ev_unloop (struct ev_loop *loop, int how = 1) 1345void ev_break (struct ev_loop *loop, int how = 1)
1346 ALIAS:
1347 unloop = 1
1316 1348
1317void 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)
1318 1350
1319unsigned int ev_pending_count (struct ev_loop *loop) 1351unsigned int ev_pending_count (struct ev_loop *loop)
1320 1352
1431 ev_fork_set (RETVAL); 1463 ev_fork_set (RETVAL);
1432 if (!ix) START (fork, RETVAL); 1464 if (!ix) START (fork, RETVAL);
1433 OUTPUT: 1465 OUTPUT:
1434 RETVAL 1466 RETVAL
1435 1467
1468
1469ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1470 ALIAS:
1471 child_ns = 1
1472 CODE:
1436#if EV_CHILD_ENABLE 1473#if EV_CHILD_ENABLE
1437
1438ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1439 ALIAS:
1440 child_ns = 1
1441 CODE:
1442 RETVAL = e_new (sizeof (ev_child), cb, ST (0)); 1474 RETVAL = e_new (sizeof (ev_child), cb, ST (0));
1443 ev_child_set (RETVAL, pid, trace); 1475 ev_child_set (RETVAL, pid, trace);
1444 if (!ix) START (child, RETVAL); 1476 if (!ix) START (child, RETVAL);
1445 OUTPUT: 1477#else
1446 RETVAL 1478 croak ("EV::child watchers not supported on this platform");
1447
1448#endif 1479#endif
1480 OUTPUT:
1481 RETVAL
1449 1482
1450ev_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)
1451 ALIAS: 1484 ALIAS:
1452 stat_ns = 1 1485 stat_ns = 1
1453 CODE: 1486 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines