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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines