… | |
… | |
933 | This is how one would do it normally anyway, the important point is that |
933 | This is how one would do it normally anyway, the important point is that |
934 | the libev application should not optimise around libev but should leave |
934 | the libev application should not optimise around libev but should leave |
935 | optimisations to libev. |
935 | optimisations to libev. |
936 | |
936 | |
937 | |
937 | |
|
|
938 | =head3 Watcher-Specific Functions |
|
|
939 | |
938 | =over 4 |
940 | =over 4 |
939 | |
941 | |
940 | =item ev_io_init (ev_io *, callback, int fd, int events) |
942 | =item ev_io_init (ev_io *, callback, int fd, int events) |
941 | |
943 | |
942 | =item ev_io_set (ev_io *, int fd, int events) |
944 | =item ev_io_set (ev_io *, int fd, int events) |
… | |
… | |
994 | ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); |
996 | ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); |
995 | |
997 | |
996 | The callback is guarenteed to be invoked only when its timeout has passed, |
998 | The callback is guarenteed to be invoked only when its timeout has passed, |
997 | but if multiple timers become ready during the same loop iteration then |
999 | but if multiple timers become ready during the same loop iteration then |
998 | order of execution is undefined. |
1000 | order of execution is undefined. |
|
|
1001 | |
|
|
1002 | =head3 Watcher-Specific Functions and Data Members |
999 | |
1003 | |
1000 | =over 4 |
1004 | =over 4 |
1001 | |
1005 | |
1002 | =item ev_timer_init (ev_timer *, callback, ev_tstamp after, ev_tstamp repeat) |
1006 | =item ev_timer_init (ev_timer *, callback, ev_tstamp after, ev_tstamp repeat) |
1003 | |
1007 | |
… | |
… | |
1109 | |
1113 | |
1110 | As with timers, the callback is guarenteed to be invoked only when the |
1114 | As with timers, the callback is guarenteed to be invoked only when the |
1111 | time (C<at>) has been passed, but if multiple periodic timers become ready |
1115 | time (C<at>) has been passed, but if multiple periodic timers become ready |
1112 | during the same loop iteration then order of execution is undefined. |
1116 | during the same loop iteration then order of execution is undefined. |
1113 | |
1117 | |
|
|
1118 | =head3 Watcher-Specific Functions and Data Members |
|
|
1119 | |
1114 | =over 4 |
1120 | =over 4 |
1115 | |
1121 | |
1116 | =item ev_periodic_init (ev_periodic *, callback, ev_tstamp at, ev_tstamp interval, reschedule_cb) |
1122 | =item ev_periodic_init (ev_periodic *, callback, ev_tstamp at, ev_tstamp interval, reschedule_cb) |
1117 | |
1123 | |
1118 | =item ev_periodic_set (ev_periodic *, ev_tstamp after, ev_tstamp repeat, reschedule_cb) |
1124 | =item ev_periodic_set (ev_periodic *, ev_tstamp after, ev_tstamp repeat, reschedule_cb) |
… | |
… | |
1264 | with the kernel (thus it coexists with your own signal handlers as long |
1270 | with the kernel (thus it coexists with your own signal handlers as long |
1265 | as you don't register any with libev). Similarly, when the last signal |
1271 | as you don't register any with libev). Similarly, when the last signal |
1266 | watcher for a signal is stopped libev will reset the signal handler to |
1272 | watcher for a signal is stopped libev will reset the signal handler to |
1267 | SIG_DFL (regardless of what it was set to before). |
1273 | SIG_DFL (regardless of what it was set to before). |
1268 | |
1274 | |
|
|
1275 | =head3 Watcher-Specific Functions and Data Members |
|
|
1276 | |
1269 | =over 4 |
1277 | =over 4 |
1270 | |
1278 | |
1271 | =item ev_signal_init (ev_signal *, callback, int signum) |
1279 | =item ev_signal_init (ev_signal *, callback, int signum) |
1272 | |
1280 | |
1273 | =item ev_signal_set (ev_signal *, int signum) |
1281 | =item ev_signal_set (ev_signal *, int signum) |
… | |
… | |
1284 | |
1292 | |
1285 | =head2 C<ev_child> - watch out for process status changes |
1293 | =head2 C<ev_child> - watch out for process status changes |
1286 | |
1294 | |
1287 | Child watchers trigger when your process receives a SIGCHLD in response to |
1295 | Child watchers trigger when your process receives a SIGCHLD in response to |
1288 | some child status changes (most typically when a child of yours dies). |
1296 | some child status changes (most typically when a child of yours dies). |
|
|
1297 | |
|
|
1298 | =head3 Watcher-Specific Functions and Data Members |
1289 | |
1299 | |
1290 | =over 4 |
1300 | =over 4 |
1291 | |
1301 | |
1292 | =item ev_child_init (ev_child *, callback, int pid) |
1302 | =item ev_child_init (ev_child *, callback, int pid) |
1293 | |
1303 | |
… | |
… | |
1361 | reader). Inotify will be used to give hints only and should not change the |
1371 | reader). Inotify will be used to give hints only and should not change the |
1362 | semantics of C<ev_stat> watchers, which means that libev sometimes needs |
1372 | semantics of C<ev_stat> watchers, which means that libev sometimes needs |
1363 | to fall back to regular polling again even with inotify, but changes are |
1373 | to fall back to regular polling again even with inotify, but changes are |
1364 | usually detected immediately, and if the file exists there will be no |
1374 | usually detected immediately, and if the file exists there will be no |
1365 | polling. |
1375 | polling. |
|
|
1376 | |
|
|
1377 | =head3 Watcher-Specific Functions and Data Members |
1366 | |
1378 | |
1367 | =over 4 |
1379 | =over 4 |
1368 | |
1380 | |
1369 | =item ev_stat_init (ev_stat *, callback, const char *path, ev_tstamp interval) |
1381 | =item ev_stat_init (ev_stat *, callback, const char *path, ev_tstamp interval) |
1370 | |
1382 | |
… | |
… | |
1453 | Apart from keeping your process non-blocking (which is a useful |
1465 | Apart from keeping your process non-blocking (which is a useful |
1454 | effect on its own sometimes), idle watchers are a good place to do |
1466 | effect on its own sometimes), idle watchers are a good place to do |
1455 | "pseudo-background processing", or delay processing stuff to after the |
1467 | "pseudo-background processing", or delay processing stuff to after the |
1456 | event loop has handled all outstanding events. |
1468 | event loop has handled all outstanding events. |
1457 | |
1469 | |
|
|
1470 | =head3 Watcher-Specific Functions and Data Members |
|
|
1471 | |
1458 | =over 4 |
1472 | =over 4 |
1459 | |
1473 | |
1460 | =item ev_idle_init (ev_signal *, callback) |
1474 | =item ev_idle_init (ev_signal *, callback) |
1461 | |
1475 | |
1462 | Initialises and configures the idle watcher - it has no parameters of any |
1476 | Initialises and configures the idle watcher - it has no parameters of any |
… | |
… | |
1529 | their job. As C<ev_check> watchers are often used to embed other event |
1543 | their job. As C<ev_check> watchers are often used to embed other event |
1530 | loops those other event loops might be in an unusable state until their |
1544 | loops those other event loops might be in an unusable state until their |
1531 | C<ev_check> watcher ran (always remind yourself to coexist peacefully with |
1545 | C<ev_check> watcher ran (always remind yourself to coexist peacefully with |
1532 | others). |
1546 | others). |
1533 | |
1547 | |
|
|
1548 | =head3 Watcher-Specific Functions and Data Members |
|
|
1549 | |
1534 | =over 4 |
1550 | =over 4 |
1535 | |
1551 | |
1536 | =item ev_prepare_init (ev_prepare *, callback) |
1552 | =item ev_prepare_init (ev_prepare *, callback) |
1537 | |
1553 | |
1538 | =item ev_check_init (ev_check *, callback) |
1554 | =item ev_check_init (ev_check *, callback) |
… | |
… | |
1739 | ev_embed_start (loop_hi, &embed); |
1755 | ev_embed_start (loop_hi, &embed); |
1740 | } |
1756 | } |
1741 | else |
1757 | else |
1742 | loop_lo = loop_hi; |
1758 | loop_lo = loop_hi; |
1743 | |
1759 | |
|
|
1760 | =head3 Watcher-Specific Functions and Data Members |
|
|
1761 | |
1744 | =over 4 |
1762 | =over 4 |
1745 | |
1763 | |
1746 | =item ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop) |
1764 | =item ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop) |
1747 | |
1765 | |
1748 | =item ev_embed_set (ev_embed *, callback, struct ev_loop *embedded_loop) |
1766 | =item ev_embed_set (ev_embed *, callback, struct ev_loop *embedded_loop) |