|
|
|
@ -6,7 +6,7 @@ |
|
|
|
|
<meta name="description" content="Pod documentation for libev" /> |
|
|
|
|
<meta name="inputfile" content="<standard input>" /> |
|
|
|
|
<meta name="outputfile" content="<standard output>" /> |
|
|
|
|
<meta name="created" content="Wed Nov 28 19:29:25 2007" /> |
|
|
|
|
<meta name="created" content="Thu Nov 29 13:21:20 2007" /> |
|
|
|
|
<meta name="generator" content="Pod::Xhtml 1.57" /> |
|
|
|
|
<link rel="stylesheet" href="http://res.tst.eu/pod.css"/></head> |
|
|
|
|
<body> |
|
|
|
@ -954,20 +954,21 @@ timer will not fire more than once per event loop iteration.</p> |
|
|
|
|
<dd> |
|
|
|
|
<p>This will act as if the timer timed out and restart it again if it is |
|
|
|
|
repeating. The exact semantics are:</p> |
|
|
|
|
<p>If the timer is started but nonrepeating, stop it.</p> |
|
|
|
|
<p>If the timer is repeating, either start it if necessary (with the repeat |
|
|
|
|
value), or reset the running timer to the repeat value.</p> |
|
|
|
|
<p>If the timer is pending, its pending status is cleared.</p> |
|
|
|
|
<p>If the timer is started but nonrepeating, stop it (as if it timed out).</p> |
|
|
|
|
<p>If the timer is repeating, either start it if necessary (with the |
|
|
|
|
<code>repeat</code> value), or reset the running timer to the <code>repeat</code> value.</p> |
|
|
|
|
<p>This sounds a bit complicated, but here is a useful and typical |
|
|
|
|
example: Imagine you have a tcp connection and you want a so-called |
|
|
|
|
idle timeout, that is, you want to be called when there have been, |
|
|
|
|
say, 60 seconds of inactivity on the socket. The easiest way to do |
|
|
|
|
this is to configure an <code>ev_timer</code> with <code>after</code>=<code>repeat</code>=<code>60</code> and calling |
|
|
|
|
example: Imagine you have a tcp connection and you want a so-called idle |
|
|
|
|
timeout, that is, you want to be called when there have been, say, 60 |
|
|
|
|
seconds of inactivity on the socket. The easiest way to do this is to |
|
|
|
|
configure an <code>ev_timer</code> with a <code>repeat</code> value of <code>60</code> and then call |
|
|
|
|
<code>ev_timer_again</code> each time you successfully read or write some data. If |
|
|
|
|
you go into an idle state where you do not expect data to travel on the |
|
|
|
|
socket, you can stop the timer, and again will automatically restart it if |
|
|
|
|
need be.</p> |
|
|
|
|
<p>You can also ignore the <code>after</code> value and <code>ev_timer_start</code> altogether |
|
|
|
|
and only ever use the <code>repeat</code> value:</p> |
|
|
|
|
socket, you can <code>ev_timer_stop</code> the timer, and <code>ev_timer_again</code> will |
|
|
|
|
automatically restart it if need be.</p> |
|
|
|
|
<p>That means you can ignore the <code>after</code> value and <code>ev_timer_start</code> |
|
|
|
|
altogether and only ever use the <code>repeat</code> value and <code>ev_timer_again</code>:</p> |
|
|
|
|
<pre> ev_timer_init (timer, callback, 0., 5.); |
|
|
|
|
ev_timer_again (loop, timer); |
|
|
|
|
... |
|
|
|
@ -978,8 +979,8 @@ and only ever use the <code>repeat</code> value:</p> |
|
|
|
|
ev_timer_again (loop, timer); |
|
|
|
|
|
|
|
|
|
</pre> |
|
|
|
|
<p>This is more efficient then stopping/starting the timer eahc time you want |
|
|
|
|
to modify its timeout value.</p> |
|
|
|
|
<p>This is more slightly efficient then stopping/starting the timer each time |
|
|
|
|
you want to modify its timeout value.</p> |
|
|
|
|
</dd> |
|
|
|
|
<dt>ev_tstamp repeat [read-write]</dt> |
|
|
|
|
<dd> |
|
|
|
|