… | |
… | |
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="Mon Nov 12 09:32:26 2007" /> |
9 | <meta name="created" content="Mon Nov 12 09:35:17 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 --> |
… | |
… | |
24 | <li><a href="#ANATOMY_OF_A_WATCHER">ANATOMY OF A WATCHER</a> |
24 | <li><a href="#ANATOMY_OF_A_WATCHER">ANATOMY OF A WATCHER</a> |
25 | <ul><li><a href="#ASSOCIATING_CUSTOM_DATA_WITH_A_WATCH">ASSOCIATING CUSTOM DATA WITH A WATCHER</a></li> |
25 | <ul><li><a href="#ASSOCIATING_CUSTOM_DATA_WITH_A_WATCH">ASSOCIATING CUSTOM DATA WITH A WATCHER</a></li> |
26 | </ul> |
26 | </ul> |
27 | </li> |
27 | </li> |
28 | <li><a href="#WATCHER_TYPES">WATCHER TYPES</a> |
28 | <li><a href="#WATCHER_TYPES">WATCHER TYPES</a> |
29 | <ul><li><a href="#code_ev_io_code_is_my_file_descripto"><code>ev_io</code> - is my file descriptor readable or writable</a></li> |
29 | <ul><li><a href="#code_ev_io_code_is_this_file_descrip"><code>ev_io</code> - is this file descriptor readable or writable</a></li> |
30 | <li><a href="#code_ev_timer_code_relative_and_opti"><code>ev_timer</code> - relative and optionally recurring timeouts</a></li> |
30 | <li><a href="#code_ev_timer_code_relative_and_opti"><code>ev_timer</code> - relative and optionally recurring timeouts</a></li> |
31 | <li><a href="#code_ev_periodic_code_to_cron_or_not"><code>ev_periodic</code> - to cron or not to cron it</a></li> |
31 | <li><a href="#code_ev_periodic_code_to_cron_or_not"><code>ev_periodic</code> - to cron or not to cron it</a></li> |
32 | <li><a href="#code_ev_signal_code_signal_me_when_a"><code>ev_signal</code> - signal me when a signal gets signalled</a></li> |
32 | <li><a href="#code_ev_signal_code_signal_me_when_a"><code>ev_signal</code> - signal me when a signal gets signalled</a></li> |
33 | <li><a href="#code_ev_child_code_wait_for_pid_stat"><code>ev_child</code> - wait for pid status changes</a></li> |
33 | <li><a href="#code_ev_child_code_wait_for_pid_stat"><code>ev_child</code> - wait for pid status changes</a></li> |
34 | <li><a href="#code_ev_idle_code_when_you_ve_got_no"><code>ev_idle</code> - when you've got nothing better to do</a></li> |
34 | <li><a href="#code_ev_idle_code_when_you_ve_got_no"><code>ev_idle</code> - when you've got nothing better to do</a></li> |
… | |
… | |
426 | <div id="WATCHER_TYPES_CONTENT"> |
426 | <div id="WATCHER_TYPES_CONTENT"> |
427 | <p>This section describes each watcher in detail, but will not repeat |
427 | <p>This section describes each watcher in detail, but will not repeat |
428 | information given in the last section.</p> |
428 | information given in the last section.</p> |
429 | |
429 | |
430 | </div> |
430 | </div> |
431 | <h2 id="code_ev_io_code_is_my_file_descripto"><code>ev_io</code> - is my file descriptor readable or writable</h2> |
431 | <h2 id="code_ev_io_code_is_this_file_descrip"><code>ev_io</code> - is this file descriptor readable or writable</h2> |
432 | <div id="code_ev_io_code_is_my_file_descripto-2"> |
432 | <div id="code_ev_io_code_is_this_file_descrip-2"> |
433 | <p>I/O watchers check whether a file descriptor is readable or writable |
433 | <p>I/O watchers check whether a file descriptor is readable or writable |
434 | in each iteration of the event loop (This behaviour is called |
434 | in each iteration of the event loop (This behaviour is called |
435 | level-triggering because you keep receiving events as long as the |
435 | level-triggering because you keep receiving events as long as the |
436 | condition persists. Remember you cna stop the watcher if you don't want to |
436 | condition persists. Remember you cna stop the watcher if you don't want to |
437 | act on the event and neither want to receive future events).</p> |
437 | act on the event and neither want to receive future events).</p> |
… | |
… | |
550 | <pre> ev_periodic_set (&periodic, 0., 3600., 0); |
550 | <pre> ev_periodic_set (&periodic, 0., 3600., 0); |
551 | |
551 | |
552 | </pre> |
552 | </pre> |
553 | <p>This doesn't mean there will always be 3600 seconds in between triggers, |
553 | <p>This doesn't mean there will always be 3600 seconds in between triggers, |
554 | but only that the the callback will be called when the system time shows a |
554 | but only that the the callback will be called when the system time shows a |
555 | full hour (UTC), or more correct, when the system time is evenly divisible |
555 | full hour (UTC), or more correctly, when the system time is evenly divisible |
556 | by 3600.</p> |
556 | by 3600.</p> |
557 | <p>Another way to think about it (for the mathematically inclined) is that |
557 | <p>Another way to think about it (for the mathematically inclined) is that |
558 | <code>ev_periodic</code> will try to run the callback in this mode at the next possible |
558 | <code>ev_periodic</code> will try to run the callback in this mode at the next possible |
559 | time where <code>time = at (mod interval)</code>, regardless of any time jumps.</p> |
559 | time where <code>time = at (mod interval)</code>, regardless of any time jumps.</p> |
560 | </dd> |
560 | </dd> |
… | |
… | |
563 | <p>In this mode the values for <code>interval</code> and <code>at</code> are both being |
563 | <p>In this mode the values for <code>interval</code> and <code>at</code> are both being |
564 | ignored. Instead, each time the periodic watcher gets scheduled, the |
564 | ignored. Instead, each time the periodic watcher gets scheduled, the |
565 | reschedule callback will be called with the watcher as first, and the |
565 | reschedule callback will be called with the watcher as first, and the |
566 | current time as second argument.</p> |
566 | current time as second argument.</p> |
567 | <p>NOTE: <i>This callback MUST NOT stop or destroy the periodic or any other |
567 | <p>NOTE: <i>This callback MUST NOT stop or destroy the periodic or any other |
568 | periodic watcher, ever, or make any event loop modificstions</i>. If you need |
568 | periodic watcher, ever, or make any event loop modifications</i>. If you need |
569 | to stop it, return 1e30 (or so, fudge fudge) and stop it afterwards.</p> |
569 | to stop it, return <code>now + 1e30</code> (or so, fudge fudge) and stop it afterwards.</p> |
|
|
570 | <p>Also, <i><this callback must always return a time that is later than the |
|
|
571 | passed <code>now</code> value </i>>. Not even <code>now</code> itself will be ok.</p> |
570 | <p>Its prototype is c<ev_tstamp (*reschedule_cb)(struct ev_periodic *w, |
572 | <p>Its prototype is c<ev_tstamp (*reschedule_cb)(struct ev_periodic *w, |
571 | ev_tstamp now)>, e.g.:</p> |
573 | ev_tstamp now)>, e.g.:</p> |
572 | <pre> static ev_tstamp my_rescheduler (struct ev_periodic *w, ev_tstamp now) |
574 | <pre> static ev_tstamp my_rescheduler (struct ev_periodic *w, ev_tstamp now) |
573 | { |
575 | { |
574 | return now + 60.; |
576 | return now + 60.; |