From 8d0f4d263d9a5601bb7d419e7db00970e288cb7e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 29 Nov 2007 12:21:05 +0000 Subject: many fixes to event emulation --- ev.html | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'ev.html') diff --git a/ev.html b/ev.html index 6c59bec..08d84d5 100644 --- a/ev.html +++ b/ev.html @@ -6,7 +6,7 @@ - + @@ -954,20 +954,21 @@ timer will not fire more than once per event loop iteration.

This will act as if the timer timed out and restart it again if it is repeating. The exact semantics are:

-

If the timer is started but nonrepeating, stop it.

-

If the timer is repeating, either start it if necessary (with the repeat -value), or reset the running timer to the repeat value.

+

If the timer is pending, its pending status is cleared.

+

If the timer is started but nonrepeating, stop it (as if it timed out).

+

If the timer is repeating, either start it if necessary (with the +repeat value), or reset the running timer to the repeat value.

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 ev_timer with after=repeat=60 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 ev_timer with a repeat value of 60 and then call ev_timer_again 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.

-

You can also ignore the after value and ev_timer_start altogether -and only ever use the repeat value:

+socket, you can ev_timer_stop the timer, and ev_timer_again will +automatically restart it if need be.

+

That means you can ignore the after value and ev_timer_start +altogether and only ever use the repeat value and ev_timer_again:

   ev_timer_init (timer, callback, 0., 5.);
    ev_timer_again (loop, timer);
    ...
@@ -978,8 +979,8 @@ and only ever use the repeat value:

ev_timer_again (loop, timer);
-

This is more efficient then stopping/starting the timer eahc time you want -to modify its timeout value.

+

This is more slightly efficient then stopping/starting the timer each time +you want to modify its timeout value.

ev_tstamp repeat [read-write]
-- cgit v1.2.3