… | |
… | |
4 | <head> |
4 | <head> |
5 | <title>libev</title> |
5 | <title>libev</title> |
6 | <meta name="description" content="Pod documentation for libev" /> |
6 | <meta name="description" content="Pod documentation for libev" /> |
7 | <meta name="inputfile" content="<standard input>" /> |
7 | <meta name="inputfile" content="<standard input>" /> |
8 | <meta name="outputfile" content="<standard output>" /> |
8 | <meta name="outputfile" content="<standard output>" /> |
9 | <meta name="created" content="Sat Dec 8 16:30:24 2007" /> |
9 | <meta name="created" content="Sat Dec 8 23:11:11 2007" /> |
10 | <meta name="generator" content="Pod::Xhtml 1.57" /> |
10 | <meta name="generator" content="Pod::Xhtml 1.57" /> |
11 | <link rel="stylesheet" href="http://res.tst.eu/pod.css"/></head> |
11 | <link rel="stylesheet" href="http://res.tst.eu/pod.css"/></head> |
12 | <body> |
12 | <body> |
13 | <div class="pod"> |
13 | <div class="pod"> |
14 | <!-- INDEX START --> |
14 | <!-- INDEX START --> |
… | |
… | |
529 | one iteration of the loop. This is useful if you are waiting for some |
529 | one iteration of the loop. This is useful if you are waiting for some |
530 | external event in conjunction with something not expressible using other |
530 | external event in conjunction with something not expressible using other |
531 | libev watchers. However, a pair of <code>ev_prepare</code>/<code>ev_check</code> watchers is |
531 | libev watchers. However, a pair of <code>ev_prepare</code>/<code>ev_check</code> watchers is |
532 | usually a better approach for this kind of thing.</p> |
532 | usually a better approach for this kind of thing.</p> |
533 | <p>Here are the gory details of what <code>ev_loop</code> does:</p> |
533 | <p>Here are the gory details of what <code>ev_loop</code> does:</p> |
|
|
534 | <pre> - Before the first iteration, call any pending watchers. |
534 | <pre> * If there are no active watchers (reference count is zero), return. |
535 | * If there are no active watchers (reference count is zero), return. |
535 | - Queue prepare watchers and then call all outstanding watchers. |
536 | - Queue all prepare watchers and then call all outstanding watchers. |
536 | - If we have been forked, recreate the kernel state. |
537 | - If we have been forked, recreate the kernel state. |
537 | - Update the kernel state with all outstanding changes. |
538 | - Update the kernel state with all outstanding changes. |
538 | - Update the "event loop time". |
539 | - Update the "event loop time". |
539 | - Calculate for how long to block. |
540 | - Calculate for how long to block. |
540 | - Block the process, waiting for any events. |
541 | - Block the process, waiting for any events. |
… | |
… | |
1483 | are ready to run (it's actually more complicated: it only runs coroutines |
1484 | are ready to run (it's actually more complicated: it only runs coroutines |
1484 | with priority higher than or equal to the event loop and one coroutine |
1485 | with priority higher than or equal to the event loop and one coroutine |
1485 | of lower priority, but only once, using idle watchers to keep the event |
1486 | of lower priority, but only once, using idle watchers to keep the event |
1486 | loop from blocking if lower-priority coroutines are active, thus mapping |
1487 | loop from blocking if lower-priority coroutines are active, thus mapping |
1487 | low-priority coroutines to idle/background tasks).</p> |
1488 | low-priority coroutines to idle/background tasks).</p> |
|
|
1489 | <p>It is recommended to give <code>ev_check</code> watchers highest (<code>EV_MAXPRI</code>) |
|
|
1490 | priority, to ensure that they are being run before any other watchers |
|
|
1491 | after the poll. Also, <code>ev_check</code> watchers (and <code>ev_prepare</code> watchers, |
|
|
1492 | too) should not activate ("feed") events into libev. While libev fully |
|
|
1493 | supports this, they will be called before other <code>ev_check</code> watchers did |
|
|
1494 | their job. As <code>ev_check</code> watchers are often used to embed other event |
|
|
1495 | loops those other event loops might be in an unusable state until their |
|
|
1496 | <code>ev_check</code> watcher ran (always remind yourself to coexist peacefully with |
|
|
1497 | others).</p> |
1488 | <dl> |
1498 | <dl> |
1489 | <dt>ev_prepare_init (ev_prepare *, callback)</dt> |
1499 | <dt>ev_prepare_init (ev_prepare *, callback)</dt> |
1490 | <dt>ev_check_init (ev_check *, callback)</dt> |
1500 | <dt>ev_check_init (ev_check *, callback)</dt> |
1491 | <dd> |
1501 | <dd> |
1492 | <p>Initialises and configures the prepare or check watcher - they have no |
1502 | <p>Initialises and configures the prepare or check watcher - they have no |