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

Comparing EV/EV.xs (file contents):
Revision 1.142 by root, Thu Oct 21 15:13:42 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) 375 const_iv (EV_, TIMER)
370 const_iv (EV_, PERIODIC) 376 const_iv (EV_, PERIODIC)
371 const_iv (EV_, SIGNAL) 377 const_iv (EV_, SIGNAL)
372 const_iv (EV_, CHILD) 378 const_iv (EV_, CHILD)
373 const_iv (EV_, STAT) 379 const_iv (EV_, STAT)
374 const_iv (EV_, IDLE) 380 const_iv (EV_, IDLE)
375 const_iv (EV_, PREPARE) 381 const_iv (EV_, PREPARE)
376 const_iv (EV_, CHECK) 382 const_iv (EV_, CHECK)
377 const_iv (EV_, EMBED) 383 const_iv (EV_, EMBED)
378 const_iv (EV_, FORK) 384 const_iv (EV_, FORK)
385 const_iv (EV_, CLEANUP)
379 const_iv (EV_, ASYNC) 386 const_iv (EV_, ASYNC)
380 const_iv (EV_, CUSTOM) 387 const_iv (EV_, CUSTOM)
381 const_iv (EV_, ERROR) 388 const_iv (EV_, ERROR)
382 389
383 const_iv (EV, RUN_NOWAIT) 390 const_iv (EV, RUN_NOWAIT)
395 const_iv (EV, BACKEND_ALL) 402 const_iv (EV, BACKEND_ALL)
396 const_iv (EV, FLAG_AUTO) 403 const_iv (EV, FLAG_AUTO)
397 const_iv (EV, FLAG_FORKCHECK) 404 const_iv (EV, FLAG_FORKCHECK)
398 const_iv (EV, FLAG_SIGNALFD) 405 const_iv (EV, FLAG_SIGNALFD)
399 const_iv (EV, FLAG_NOENV) 406 const_iv (EV, FLAG_NOENV)
400 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
401 const_iv (EV, FLAG_NOINOTIFY) 407 const_iv (EV, FLAG_NOINOTIFY)
402 408
403 const_iv (EV_, VERSION_MAJOR) 409 const_iv (EV_, VERSION_MAJOR)
404 const_iv (EV_, VERSION_MINOR) 410 const_iv (EV_, VERSION_MINOR)
405#if EV_COMPAT3 411#if EV_COMPAT3
412 const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */
406 const_iv (EV_, TIMER) 413 const_iv (EV_, TIMEOUT)
407
408 const_iv (EV, LOOP_NONBLOCK) 414 const_iv (EV, LOOP_NONBLOCK)
409 const_iv (EV, LOOP_ONESHOT) 415 const_iv (EV, LOOP_ONESHOT)
410
411 const_iv (EV, UNLOOP_CANCEL) 416 const_iv (EV, UNLOOP_CANCEL)
412 const_iv (EV, UNLOOP_ONE) 417 const_iv (EV, UNLOOP_ONE)
413 const_iv (EV, UNLOOP_ALL) 418 const_iv (EV, UNLOOP_ALL)
414#endif 419#endif
415 }; 420 };
428 stash_check = gv_stashpv ("EV::Check" , 1); 433 stash_check = gv_stashpv ("EV::Check" , 1);
429 stash_child = gv_stashpv ("EV::Child" , 1); 434 stash_child = gv_stashpv ("EV::Child" , 1);
430 stash_embed = gv_stashpv ("EV::Embed" , 1); 435 stash_embed = gv_stashpv ("EV::Embed" , 1);
431 stash_stat = gv_stashpv ("EV::Stat" , 1); 436 stash_stat = gv_stashpv ("EV::Stat" , 1);
432 stash_fork = gv_stashpv ("EV::Fork" , 1); 437 stash_fork = gv_stashpv ("EV::Fork" , 1);
438 stash_cleanup = gv_stashpv ("EV::Cleanup" , 1);
433 stash_async = gv_stashpv ("EV::Async" , 1); 439 stash_async = gv_stashpv ("EV::Async" , 1);
434 440
435 { 441 {
436 SV *sv = perl_get_sv ("EV::API", TRUE); 442 SV *sv = perl_get_sv ("EV::API", TRUE);
437 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ 443 perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */
494 evapi.embed_start = ev_embed_start; 500 evapi.embed_start = ev_embed_start;
495 evapi.embed_stop = ev_embed_stop; 501 evapi.embed_stop = ev_embed_stop;
496 evapi.embed_sweep = ev_embed_sweep; 502 evapi.embed_sweep = ev_embed_sweep;
497 evapi.fork_start = ev_fork_start; 503 evapi.fork_start = ev_fork_start;
498 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;
499 evapi.async_start = ev_async_start; 507 evapi.async_start = ev_async_start;
500 evapi.async_stop = ev_async_stop; 508 evapi.async_stop = ev_async_stop;
501 evapi.async_send = ev_async_send; 509 evapi.async_send = ev_async_send;
502 evapi.clear_pending = ev_clear_pending; 510 evapi.clear_pending = ev_clear_pending;
503 evapi.invoke = ev_invoke; 511 evapi.invoke = ev_invoke;
504 512
505 sv_setiv (sv, (IV)&evapi); 513 sv_setiv (sv, (IV)&evapi);
506 SvREADONLY_on (sv); 514 SvREADONLY_on (sv);
507 } 515 }
508#if !defined(_WIN32) && !defined(_MINIX) 516#if !defined(_WIN32) && !defined(_MINIX)
509 pthread_atfork (0, 0, ev_default_fork); 517 pthread_atfork (0, 0, default_fork);
510#endif 518#endif
511} 519}
512 520
513SV *ev_default_loop (unsigned int flags = 0) 521SV *ev_default_loop (unsigned int flags = 0)
514 CODE: 522 CODE:
528 OUTPUT: 536 OUTPUT:
529 RETVAL 537 RETVAL
530 538
531void ev_default_destroy () 539void ev_default_destroy ()
532 CODE: 540 CODE:
533 ev_default_destroy (); 541 ev_loop_destroy (EV_DEFAULT_UC);
534 SvREFCNT_dec (default_loop_sv); 542 SvREFCNT_dec (default_loop_sv);
535 default_loop_sv = 0; 543 default_loop_sv = 0;
536 544
537unsigned int ev_supported_backends () 545unsigned int ev_supported_backends ()
538 546
713 ev_fork_set (RETVAL); 721 ev_fork_set (RETVAL);
714 if (!ix) START (fork, RETVAL); 722 if (!ix) START (fork, RETVAL);
715 OUTPUT: 723 OUTPUT:
716 RETVAL 724 RETVAL
717 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
718 735
719ev_child *child (int pid, int trace, SV *cb) 736ev_child *child (int pid, int trace, SV *cb)
720 ALIAS: 737 ALIAS:
721 child_ns = 1 738 child_ns = 1
722 CODE: 739 CODE:
1102 1119
1103void DESTROY (ev_fork *w) 1120void DESTROY (ev_fork *w)
1104 CODE: 1121 CODE:
1105 STOP (fork, w); 1122 STOP (fork, w);
1106 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
1107 1145
1108MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ 1146MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_
1109 1147
1110#if EV_CHILD_ENABLE 1148#if EV_CHILD_ENABLE
1111 1149
1303 OUTPUT: 1341 OUTPUT:
1304 RETVAL 1342 RETVAL
1305 1343
1306void DESTROY (struct ev_loop *loop) 1344void DESTROY (struct ev_loop *loop)
1307 CODE: 1345 CODE:
1308 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)
1309 ev_loop_destroy (loop); 1349 ev_loop_destroy (loop);
1310 1350
1311void ev_loop_fork (struct ev_loop *loop) 1351void ev_loop_fork (struct ev_loop *loop)
1312 1352
1313NV ev_now (struct ev_loop *loop) 1353NV ev_now (struct ev_loop *loop)
1461 ev_fork_set (RETVAL); 1501 ev_fork_set (RETVAL);
1462 if (!ix) START (fork, RETVAL); 1502 if (!ix) START (fork, RETVAL);
1463 OUTPUT: 1503 OUTPUT:
1464 RETVAL 1504 RETVAL
1465 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
1466 1515
1467ev_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)
1468 ALIAS: 1517 ALIAS:
1469 child_ns = 1 1518 child_ns = 1
1470 CODE: 1519 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines