ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.3
(Generate patch)

Comparing libev/ev.3 (file contents):
Revision 1.33 by root, Wed Nov 28 18:29:29 2007 UTC vs.
Revision 1.34 by root, Thu Nov 29 12:21:21 2007 UTC

127.\} 127.\}
128.rm #[ #] #H #V #F C 128.rm #[ #] #H #V #F C
129.\" ======================================================================== 129.\" ========================================================================
130.\" 130.\"
131.IX Title ""<STANDARD INPUT>" 1" 131.IX Title ""<STANDARD INPUT>" 1"
132.TH "<STANDARD INPUT>" 1 "2007-11-28" "perl v5.8.8" "User Contributed Perl Documentation" 132.TH "<STANDARD INPUT>" 1 "2007-11-29" "perl v5.8.8" "User Contributed Perl Documentation"
133.SH "NAME" 133.SH "NAME"
134libev \- a high performance full\-featured event loop written in C 134libev \- a high performance full\-featured event loop written in C
135.SH "SYNOPSIS" 135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS" 136.IX Header "SYNOPSIS"
137.Vb 1 137.Vb 1
1071.IP "ev_timer_again (loop)" 4 1071.IP "ev_timer_again (loop)" 4
1072.IX Item "ev_timer_again (loop)" 1072.IX Item "ev_timer_again (loop)"
1073This will act as if the timer timed out and restart it again if it is 1073This will act as if the timer timed out and restart it again if it is
1074repeating. The exact semantics are: 1074repeating. The exact semantics are:
1075.Sp 1075.Sp
1076If the timer is pending, its pending status is cleared.
1077.Sp
1076If the timer is started but nonrepeating, stop it. 1078If the timer is started but nonrepeating, stop it (as if it timed out).
1077.Sp 1079.Sp
1078If the timer is repeating, either start it if necessary (with the repeat 1080If the timer is repeating, either start it if necessary (with the
1079value), or reset the running timer to the repeat value. 1081\&\f(CW\*(C`repeat\*(C'\fR value), or reset the running timer to the \f(CW\*(C`repeat\*(C'\fR value.
1080.Sp 1082.Sp
1081This sounds a bit complicated, but here is a useful and typical 1083This sounds a bit complicated, but here is a useful and typical
1082example: Imagine you have a tcp connection and you want a so-called 1084example: Imagine you have a tcp connection and you want a so-called idle
1083idle timeout, that is, you want to be called when there have been, 1085timeout, that is, you want to be called when there have been, say, 60
1084say, 60 seconds of inactivity on the socket. The easiest way to do 1086seconds of inactivity on the socket. The easiest way to do this is to
1085this is to configure an \f(CW\*(C`ev_timer\*(C'\fR with \f(CW\*(C`after\*(C'\fR=\f(CW\*(C`repeat\*(C'\fR=\f(CW60\fR and calling 1087configure an \f(CW\*(C`ev_timer\*(C'\fR with a \f(CW\*(C`repeat\*(C'\fR value of \f(CW60\fR and then call
1086\&\f(CW\*(C`ev_timer_again\*(C'\fR each time you successfully read or write some data. If 1088\&\f(CW\*(C`ev_timer_again\*(C'\fR each time you successfully read or write some data. If
1087you go into an idle state where you do not expect data to travel on the 1089you go into an idle state where you do not expect data to travel on the
1088socket, you can stop the timer, and again will automatically restart it if 1090socket, you can \f(CW\*(C`ev_timer_stop\*(C'\fR the timer, and \f(CW\*(C`ev_timer_again\*(C'\fR will
1089need be. 1091automatically restart it if need be.
1090.Sp 1092.Sp
1091You can also ignore the \f(CW\*(C`after\*(C'\fR value and \f(CW\*(C`ev_timer_start\*(C'\fR altogether 1093That means you can ignore the \f(CW\*(C`after\*(C'\fR value and \f(CW\*(C`ev_timer_start\*(C'\fR
1092and only ever use the \f(CW\*(C`repeat\*(C'\fR value: 1094altogether and only ever use the \f(CW\*(C`repeat\*(C'\fR value and \f(CW\*(C`ev_timer_again\*(C'\fR:
1093.Sp 1095.Sp
1094.Vb 8 1096.Vb 8
1095\& ev_timer_init (timer, callback, 0., 5.); 1097\& ev_timer_init (timer, callback, 0., 5.);
1096\& ev_timer_again (loop, timer); 1098\& ev_timer_again (loop, timer);
1097\& ... 1099\& ...
1100\& ... 1102\& ...
1101\& timer->again = 10.; 1103\& timer->again = 10.;
1102\& ev_timer_again (loop, timer); 1104\& ev_timer_again (loop, timer);
1103.Ve 1105.Ve
1104.Sp 1106.Sp
1105This is more efficient then stopping/starting the timer eahc time you want 1107This is more slightly efficient then stopping/starting the timer each time
1106to modify its timeout value. 1108you want to modify its timeout value.
1107.IP "ev_tstamp repeat [read\-write]" 4 1109.IP "ev_tstamp repeat [read\-write]" 4
1108.IX Item "ev_tstamp repeat [read-write]" 1110.IX Item "ev_tstamp repeat [read-write]"
1109The current \f(CW\*(C`repeat\*(C'\fR value. Will be used each time the watcher times out 1111The current \f(CW\*(C`repeat\*(C'\fR value. Will be used each time the watcher times out
1110or \f(CW\*(C`ev_timer_again\*(C'\fR is called and determines the next timeout (if any), 1112or \f(CW\*(C`ev_timer_again\*(C'\fR is called and determines the next timeout (if any),
1111which is also when any modifications are taken into account. 1113which is also when any modifications are taken into account.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines