… | |
… | |
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:58:27 2007" /> |
9 | <meta name="created" content="Mon Nov 12 10:01:12 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 --> |
… | |
… | |
99 | to the double type in C.</p> |
99 | to the double type in C.</p> |
100 | |
100 | |
101 | </div> |
101 | </div> |
102 | <h1 id="GLOBAL_FUNCTIONS">GLOBAL FUNCTIONS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
102 | <h1 id="GLOBAL_FUNCTIONS">GLOBAL FUNCTIONS</h1><p><a href="#TOP" class="toplink">Top</a></p> |
103 | <div id="GLOBAL_FUNCTIONS_CONTENT"> |
103 | <div id="GLOBAL_FUNCTIONS_CONTENT"> |
|
|
104 | <p>These functions can be called anytime, even before initialising the |
|
|
105 | library in any way.</p> |
104 | <dl> |
106 | <dl> |
105 | <dt>ev_tstamp ev_time ()</dt> |
107 | <dt>ev_tstamp ev_time ()</dt> |
106 | <dd> |
108 | <dd> |
107 | <p>Returns the current time as libev would use it.</p> |
109 | <p>Returns the current time as libev would use it.</p> |
108 | </dd> |
110 | </dd> |
… | |
… | |
567 | <dd> |
569 | <dd> |
568 | <p>In this mode the values for <code>interval</code> and <code>at</code> are both being |
570 | <p>In this mode the values for <code>interval</code> and <code>at</code> are both being |
569 | ignored. Instead, each time the periodic watcher gets scheduled, the |
571 | ignored. Instead, each time the periodic watcher gets scheduled, the |
570 | reschedule callback will be called with the watcher as first, and the |
572 | reschedule callback will be called with the watcher as first, and the |
571 | current time as second argument.</p> |
573 | current time as second argument.</p> |
572 | <p>NOTE: <i>This callback MUST NOT stop or destroy the periodic or any other |
574 | <p>NOTE: <i>This callback MUST NOT stop or destroy any periodic watcher, |
573 | periodic watcher, ever, or make any event loop modifications</i>. If you need |
575 | ever, or make any event loop modifications</i>. If you need to stop it, |
574 | to stop it, return <code>now + 1e30</code> (or so, fudge fudge) and stop it afterwards.</p> |
576 | return <code>now + 1e30</code> (or so, fudge fudge) and stop it afterwards (e.g. by |
575 | <p>Also, <i>this callback must always return a time that is later than the |
577 | starting a prepare watcher).</p> |
576 | passed <code>now</code> value</i>. Not even <code>now</code> itself will be ok.</p> |
|
|
577 | <p>Its prototype is <code>ev_tstamp (*reschedule_cb)(struct ev_periodic *w, |
578 | <p>Its prototype is <code>ev_tstamp (*reschedule_cb)(struct ev_periodic *w, |
578 | ev_tstamp now)</code>, e.g.:</p> |
579 | ev_tstamp now)</code>, e.g.:</p> |
579 | <pre> static ev_tstamp my_rescheduler (struct ev_periodic *w, ev_tstamp now) |
580 | <pre> static ev_tstamp my_rescheduler (struct ev_periodic *w, ev_tstamp now) |
580 | { |
581 | { |
581 | return now + 60.; |
582 | return now + 60.; |
… | |
… | |
584 | </pre> |
585 | </pre> |
585 | <p>It must return the next time to trigger, based on the passed time value |
586 | <p>It must return the next time to trigger, based on the passed time value |
586 | (that is, the lowest time value larger than to the second argument). It |
587 | (that is, the lowest time value larger than to the second argument). It |
587 | will usually be called just before the callback will be triggered, but |
588 | will usually be called just before the callback will be triggered, but |
588 | might be called at other times, too.</p> |
589 | might be called at other times, too.</p> |
|
|
590 | <p>NOTE: <i>This callback must always return a time that is later than the |
|
|
591 | passed <code>now</code> value</i>. Not even <code>now</code> itself will do, it must be larger.</p> |
589 | <p>This can be used to create very complex timers, such as a timer that |
592 | <p>This can be used to create very complex timers, such as a timer that |
590 | triggers on each midnight, local time. To do this, you would calculate the |
593 | triggers on each midnight, local time. To do this, you would calculate the |
591 | next midnight after <code>now</code> and return the timestamp value for this. How you do this |
594 | next midnight after <code>now</code> and return the timestamp value for this. How you do this |
592 | is, again, up to you (but it is not trivial).</p> |
595 | is, again, up to you (but it is not trivial).</p> |
593 | </dd> |
596 | </dd> |