diff options
author | root <root> | 2007-11-29 12:21:05 +0000 |
---|---|---|
committer | root <root> | 2007-11-29 12:21:05 +0000 |
commit | 8d0f4d263d9a5601bb7d419e7db00970e288cb7e (patch) | |
tree | f1eb4dde57119a2d01d733eb8d897414e7720a52 /ev.pod | |
parent | e036fde31e607a47af3e63e9c23cef34d88a2582 (diff) |
many fixes to event emulation
Diffstat (limited to 'ev.pod')
-rw-r--r-- | ev.pod | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -918,23 +918,25 @@ 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 pending, its pending status is cleared. -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 started but nonrepeating, stop it (as if it timed out). + +If the timer is repeating, either start it if necessary (with the +C<repeat> value), or reset the running timer to the C<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 C<ev_timer> with C<after>=C<repeat>=C<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 C<ev_timer> with a C<repeat> value of C<60> and then call C<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. +socket, you can C<ev_timer_stop> the timer, and C<ev_timer_again> will +automatically restart it if need be. -You can also ignore the C<after> value and C<ev_timer_start> altogether -and only ever use the C<repeat> value: +That means you can ignore the C<after> value and C<ev_timer_start> +altogether and only ever use the C<repeat> value and C<ev_timer_again>: ev_timer_init (timer, callback, 0., 5.); ev_timer_again (loop, timer); @@ -945,8 +947,8 @@ and only ever use the C<repeat> value: timer->again = 10.; 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. =item ev_tstamp repeat [read-write] |