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

Comparing EV/EV.xs (file contents):
Revision 1.141 by root, Thu Jul 8 00:45:03 2010 UTC vs.
Revision 1.147 by root, Thu Oct 28 04:59:35 2010 UTC

120 *stash_idle, 120 *stash_idle,
121 *stash_prepare, 121 *stash_prepare,
122 *stash_check, 122 *stash_check,
123 *stash_embed, 123 *stash_embed,
124 *stash_fork, 124 *stash_fork,
125 *stash_cleanup,
125 *stash_async; 126 *stash_async;
126 127
127///////////////////////////////////////////////////////////////////////////// 128/////////////////////////////////////////////////////////////////////////////
128// Event 129// Event
129 130
340 croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh)); 341 croak ("illegal file descriptor or filehandle (either no attached file descriptor or illegal value): %s", SvPV_nolen (fh));
341 342
342#define CHECK_SIG(sv,num) if ((num) < 0) \ 343#define CHECK_SIG(sv,num) if ((num) < 0) \
343 croak ("illegal signal number or name: %s", SvPV_nolen (sv)); 344 croak ("illegal signal number or name: %s", SvPV_nolen (sv));
344 345
346EV_INLINE default_fork (void)
347{
348 ev_loop_fork (EV_DEFAULT_UC);
349}
350
345///////////////////////////////////////////////////////////////////////////// 351/////////////////////////////////////////////////////////////////////////////
346// XS interface functions 352// XS interface functions
347 353
348MODULE = EV PACKAGE = EV PREFIX = ev_ 354MODULE = EV PACKAGE = EV PREFIX = ev_
349 355
364 const_iv (EV_, UNDEF) 370 const_iv (EV_, UNDEF)
365 const_iv (EV_, NONE) 371 const_iv (EV_, NONE)
366 const_iv (EV_, READ) 372 const_iv (EV_, READ)
367 const_iv (EV_, WRITE) 373 const_iv (EV_, WRITE)
368 const_iv (EV_, IO) 374 const_iv (EV_, IO)
369 const_iv (EV_, TIMEOUT) /* deprecated */
370 const_iv (EV_, TIMER) 375 const_iv (EV_, TIMER)
371 const_iv (EV_, PERIODIC) 376 const_iv (EV_, PERIODIC)
372 const_iv (EV_, SIGNAL) 377 const_iv (EV_, SIGNAL)
373 const_iv (EV_, CHILD) 378 const_iv (EV_, CHILD)
374 const_iv (EV_, STAT) 379 const_iv (EV_, STAT)
375 const_iv (EV_, IDLE) 380 const_iv (EV_, IDLE)
376 const_iv (EV_, PREPARE) 381 const_iv (EV_, PREPARE)
377 const_iv (EV_, CHECK) 382 const_iv (EV_, CHECK)
378 const_iv (EV_, EMBED) 383 const_iv (EV_, EMBED)
379 const_iv (EV_, FORK) 384 const_iv (EV_, FORK)
385 const_iv (EV_, CLEANUP)
380 const_iv (EV_, ASYNC) 386 const_iv (EV_, ASYNC)
381 const_iv (EV_, CUSTOM) 387 const_iv (EV_, CUSTOM)
382 const_iv (EV_, ERROR) 388 const_iv (EV_, ERROR)
383 389
384 const_iv (EV, LOOP_NONBLOCK)
385 const_iv (EV, LOOP_ONESHOT)
386
387 const_iv (EV, UNLOOP_CANCEL) 390 const_iv (EV, RUN_NOWAIT)
388 const_iv (EV, UNLOOP_ONE) 391 const_iv (EV, RUN_ONCE)
392
393 const_iv (EV, BREAK_CANCEL)
394 const_iv (EV, BREAK_ONE)
389 const_iv (EV, UNLOOP_ALL) 395 const_iv (EV, BREAK_ALL)
390
391 const_iv (EV, BACKEND_SELECT) 396 const_iv (EV, BACKEND_SELECT)
392 const_iv (EV, BACKEND_POLL) 397 const_iv (EV, BACKEND_POLL)
393 const_iv (EV, BACKEND_EPOLL) 398 const_iv (EV, BACKEND_EPOLL)
394 const_iv (EV, BACKEND_KQUEUE) 399 const_iv (EV, BACKEND_KQUEUE)
395 const_iv (EV, BACKEND_DEVPOLL) 400 const_iv (EV, BACKEND_DEVPOLL)
397 const_iv (EV, BACKEND_ALL) 402 const_iv (EV, BACKEND_ALL)
398 const_iv (EV, FLAG_AUTO) 403 const_iv (EV, FLAG_AUTO)
399 const_iv (EV, FLAG_FORKCHECK) 404 const_iv (EV, FLAG_FORKCHECK)
400 const_iv (EV, FLAG_SIGNALFD) 405 const_iv (EV, FLAG_SIGNALFD)
401 const_iv (EV, FLAG_NOENV) 406 const_iv (EV, FLAG_NOENV)
402 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
403 const_iv (EV, FLAG_NOINOTIFY) 407 const_iv (EV, FLAG_NOINOTIFY)
404 408
405 const_iv (EV_, VERSION_MAJOR) 409 const_iv (EV_, VERSION_MAJOR)
406 const_iv (EV_, VERSION_MINOR) 410 const_iv (EV_, VERSION_MINOR)
411#if EV_COMPAT3
412 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
413 const_iv (EV_, TIMEOUT)
414 const_iv (EV, LOOP_NONBLOCK)
415 const_iv (EV, LOOP_ONESHOT)
416 const_iv (EV, UNLOOP_CANCEL)
417 const_iv (EV, UNLOOP_ONE)
418 const_iv (EV, UNLOOP_ALL)
419#endif
407 }; 420 };
408 421
409 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 422 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
410 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 423 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
411 424
420 stash_check = gv_stashpv ("EV::Check" , 1); 433 stash_check = gv_stashpv ("EV::Check" , 1);
421 stash_child = gv_stashpv ("EV::Child" , 1); 434 stash_child = gv_stashpv ("EV::Child" , 1);
422 stash_embed = gv_stashpv ("EV::Embed" , 1); 435 stash_embed = gv_stashpv ("EV::Embed" , 1);
423 stash_stat = gv_stashpv ("EV::Stat" , 1); 436 stash_stat = gv_stashpv ("EV::Stat" , 1);
424 stash_fork = gv_stashpv ("EV::Fork" , 1); 437 stash_fork = gv_stashpv ("EV::Fork" , 1);
438 stash_cleanup = gv_stashpv ("EV::Cleanup" , 1);
425 stash_async = gv_stashpv ("EV::Async" , 1); 439 stash_async = gv_stashpv ("EV::Async" , 1);
426 440
427 { 441 {
428 SV *sv = perl_get_sv ("EV::API", TRUE); 442 SV *sv = perl_get_sv ("EV::API", TRUE);
429 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 443 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
448 evapi.now = ev_now; 462 evapi.now = ev_now;
449 evapi.now_update = ev_now_update; 463 evapi.now_update = ev_now_update;
450 evapi.suspend = ev_suspend; 464 evapi.suspend = ev_suspend;
451 evapi.resume = ev_resume; 465 evapi.resume = ev_resume;
452 evapi.backend = ev_backend; 466 evapi.backend = ev_backend;
453 evapi.unloop = ev_unloop; 467 evapi.break_ = ev_break;
454 evapi.invoke_pending = ev_invoke_pending; 468 evapi.invoke_pending = ev_invoke_pending;
455 evapi.pending_count = ev_pending_count; 469 evapi.pending_count = ev_pending_count;
456 evapi.verify = ev_verify; 470 evapi.verify = ev_verify;
457 evapi.set_loop_release_cb = ev_set_loop_release_cb; 471 evapi.set_loop_release_cb = ev_set_loop_release_cb;
458 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; 472 evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb;
459 evapi.ref = ev_ref; 473 evapi.ref = ev_ref;
460 evapi.unref = ev_unref; 474 evapi.unref = ev_unref;
461 evapi.loop = ev_loop; 475 evapi.run = ev_run;
462 evapi.once = ev_once; 476 evapi.once = ev_once;
463 evapi.io_start = ev_io_start; 477 evapi.io_start = ev_io_start;
464 evapi.io_stop = ev_io_stop; 478 evapi.io_stop = ev_io_stop;
465 evapi.timer_start = ev_timer_start; 479 evapi.timer_start = ev_timer_start;
466 evapi.timer_stop = ev_timer_stop; 480 evapi.timer_stop = ev_timer_stop;
486 evapi.embed_start = ev_embed_start; 500 evapi.embed_start = ev_embed_start;
487 evapi.embed_stop = ev_embed_stop; 501 evapi.embed_stop = ev_embed_stop;
488 evapi.embed_sweep = ev_embed_sweep; 502 evapi.embed_sweep = ev_embed_sweep;
489 evapi.fork_start = ev_fork_start; 503 evapi.fork_start = ev_fork_start;
490 evapi.fork_stop = ev_fork_stop; 504 evapi.fork_stop = ev_fork_stop;
505 evapi.cleanup_start = ev_cleanup_start;
506 evapi.cleanup_stop = ev_cleanup_stop;
491 evapi.async_start = ev_async_start; 507 evapi.async_start = ev_async_start;
492 evapi.async_stop = ev_async_stop; 508 evapi.async_stop = ev_async_stop;
493 evapi.async_send = ev_async_send; 509 evapi.async_send = ev_async_send;
494 evapi.clear_pending = ev_clear_pending; 510 evapi.clear_pending = ev_clear_pending;
495 evapi.invoke = ev_invoke; 511 evapi.invoke = ev_invoke;
496 512
497 sv_setiv (sv, (IV)&evapi); 513 sv_setiv (sv, (IV)&evapi);
498 SvREADONLY_on (sv); 514 SvREADONLY_on (sv);
499 } 515 }
500#if !defined(_WIN32) && !defined(_MINIX) 516#if !defined(_WIN32) && !defined(_MINIX)
501 pthread_atfork (0, 0, ev_default_fork); 517 pthread_atfork (0, 0, default_fork);
502#endif 518#endif
503} 519}
504 520
505SV *ev_default_loop (unsigned int flags = 0) 521SV *ev_default_loop (unsigned int flags = 0)
506 CODE: 522 CODE:
520 OUTPUT: 536 OUTPUT:
521 RETVAL 537 RETVAL
522 538
523void ev_default_destroy () 539void ev_default_destroy ()
524 CODE: 540 CODE:
525 ev_default_destroy (); 541 ev_loop_destroy (EV_DEFAULT_UC);
526 SvREFCNT_dec (default_loop_sv); 542 SvREFCNT_dec (default_loop_sv);
527 default_loop_sv = 0; 543 default_loop_sv = 0;
528 544
529unsigned int ev_supported_backends () 545unsigned int ev_supported_backends ()
530 546
550 566
551unsigned int ev_backend () 567unsigned int ev_backend ()
552 C_ARGS: evapi.default_loop 568 C_ARGS: evapi.default_loop
553 569
554void ev_verify () 570void ev_verify ()
571 ALIAS:
572 loop_verify = 1
555 C_ARGS: evapi.default_loop 573 C_ARGS: evapi.default_loop
556 574
557unsigned int ev_iteration () 575unsigned int ev_iteration ()
576 ALIAS:
577 loop_count = 1
558 C_ARGS: evapi.default_loop 578 C_ARGS: evapi.default_loop
559 579
560unsigned int ev_depth () 580unsigned int ev_depth ()
581 ALIAS:
582 loop_depth = 1
561 C_ARGS: evapi.default_loop 583 C_ARGS: evapi.default_loop
562 584
563void ev_set_io_collect_interval (NV interval) 585void ev_set_io_collect_interval (NV interval)
564 C_ARGS: evapi.default_loop, interval 586 C_ARGS: evapi.default_loop, interval
565 587
566void ev_set_timeout_collect_interval (NV interval) 588void ev_set_timeout_collect_interval (NV interval)
567 C_ARGS: evapi.default_loop, interval 589 C_ARGS: evapi.default_loop, interval
568 590
569void ev_loop (int flags = 0) 591void ev_run (int flags = 0)
592 ALIAS:
593 loop = 1
570 C_ARGS: evapi.default_loop, flags 594 C_ARGS: evapi.default_loop, flags
571 595
572void ev_unloop (int how = EVUNLOOP_ONE) 596void ev_break (int how = EVBREAK_ONE)
597 ALIAS:
598 unloop = 1
573 C_ARGS: evapi.default_loop, how 599 C_ARGS: evapi.default_loop, how
574 600
575void ev_feed_fd_event (int fd, int revents = EV_NONE) 601void ev_feed_fd_event (int fd, int revents = EV_NONE)
576 C_ARGS: evapi.default_loop, fd, revents 602 C_ARGS: evapi.default_loop, fd, revents
577 603
695 ev_fork_set (RETVAL); 721 ev_fork_set (RETVAL);
696 if (!ix) START (fork, RETVAL); 722 if (!ix) START (fork, RETVAL);
697 OUTPUT: 723 OUTPUT:
698 RETVAL 724 RETVAL
699 725
726ev_cleanup *cleanup (SV *cb)
727 ALIAS:
728 cleanup_ns = 1
729 CODE:
730 RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv);
731 ev_cleanup_set (RETVAL);
732 if (!ix) START (cleanup, RETVAL);
733 OUTPUT:
734 RETVAL
700 735
701ev_child *child (int pid, int trace, SV *cb) 736ev_child *child (int pid, int trace, SV *cb)
702 ALIAS: 737 ALIAS:
703 child_ns = 1 738 child_ns = 1
704 CODE: 739 CODE:
1084 1119
1085void DESTROY (ev_fork *w) 1120void DESTROY (ev_fork *w)
1086 CODE: 1121 CODE:
1087 STOP (fork, w); 1122 STOP (fork, w);
1088 e_destroy (w); 1123 e_destroy (w);
1124
1125MODULE = EV PACKAGE = EV::Cleanup PREFIX = ev_cleanup_
1126
1127void ev_cleanup_start (ev_cleanup *w)
1128 CODE:
1129 START (cleanup, w);
1130
1131void ev_cleanup_stop (ev_cleanup *w)
1132 CODE:
1133 STOP (cleanup, w);
1134
1135void DESTROY (ev_cleanup *w)
1136 CODE:
1137 STOP (cleanup, w);
1138 e_destroy (w);
1139
1140int keepalive (ev_watcher *w, int new_value = 0)
1141 CODE:
1142 RETVAL = 0;
1143 OUTPUT:
1144 RETVAL
1089 1145
1090MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 1146MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
1091 1147
1092#if EV_CHILD_ENABLE 1148#if EV_CHILD_ENABLE
1093 1149
1285 OUTPUT: 1341 OUTPUT:
1286 RETVAL 1342 RETVAL
1287 1343
1288void DESTROY (struct ev_loop *loop) 1344void DESTROY (struct ev_loop *loop)
1289 CODE: 1345 CODE:
1290 if (loop != evapi.default_loop) /* global destruction sucks */ 1346 /* 1. the default loop shouldn't be freed by destroying it'S pelr loop object */
1347 /* 2. not doing so helps avoid many global destruction bugs in perl, too */
1348 if (loop != evapi.default_loop)
1291 ev_loop_destroy (loop); 1349 ev_loop_destroy (loop);
1292 1350
1293void ev_loop_fork (struct ev_loop *loop) 1351void ev_loop_fork (struct ev_loop *loop)
1294 1352
1353NV ev_now (struct ev_loop *loop)
1354
1355void ev_now_update (struct ev_loop *loop)
1356
1357void ev_suspend (struct ev_loop *loop)
1358
1359void ev_resume (struct ev_loop *loop)
1360
1361void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1362
1363void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1364
1365unsigned int ev_backend (struct ev_loop *loop)
1366
1295void ev_verify (struct ev_loop *loop) 1367void ev_verify (struct ev_loop *loop)
1296 1368 ALIAS:
1297NV ev_now (struct ev_loop *loop) 1369 loop_verify = 1
1298
1299void ev_now_update (struct ev_loop *loop)
1300
1301void ev_suspend (struct ev_loop *loop)
1302
1303void ev_resume (struct ev_loop *loop)
1304
1305void ev_set_io_collect_interval (struct ev_loop *loop, NV interval)
1306
1307void ev_set_timeout_collect_interval (struct ev_loop *loop, NV interval)
1308
1309unsigned int ev_backend (struct ev_loop *loop)
1310 1370
1311unsigned int ev_iteration (struct ev_loop *loop) 1371unsigned int ev_iteration (struct ev_loop *loop)
1372 ALIAS:
1373 loop_count = 1
1312 1374
1313unsigned int ev_depth (struct ev_loop *loop) 1375unsigned int ev_depth (struct ev_loop *loop)
1376 ALIAS:
1377 loop_depth = 1
1314 1378
1315void ev_loop (struct ev_loop *loop, int flags = 0) 1379void ev_run (struct ev_loop *loop, int flags = 0)
1380 ALIAS:
1381 loop = 1
1316 1382
1317void ev_unloop (struct ev_loop *loop, int how = 1) 1383void ev_break (struct ev_loop *loop, int how = 1)
1384 ALIAS:
1385 unloop = 1
1318 1386
1319void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) 1387void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE)
1320 1388
1321unsigned int ev_pending_count (struct ev_loop *loop) 1389unsigned int ev_pending_count (struct ev_loop *loop)
1322 1390
1433 ev_fork_set (RETVAL); 1501 ev_fork_set (RETVAL);
1434 if (!ix) START (fork, RETVAL); 1502 if (!ix) START (fork, RETVAL);
1435 OUTPUT: 1503 OUTPUT:
1436 RETVAL 1504 RETVAL
1437 1505
1506ev_cleanup *cleanup (struct ev_loop *loop, SV *cb)
1507 ALIAS:
1508 cleanup_ns = 1
1509 CODE:
1510 RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0));
1511 ev_cleanup_set (RETVAL);
1512 if (!ix) START (cleanup, RETVAL);
1513 OUTPUT:
1514 RETVAL
1438 1515
1439ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) 1516ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb)
1440 ALIAS: 1517 ALIAS:
1441 child_ns = 1 1518 child_ns = 1
1442 CODE: 1519 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines