… | |
… | |
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" |
134 | libev \- a high performance full\-featured event loop written in C |
134 | libev \- 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)" |
1073 | This will act as if the timer timed out and restart it again if it is |
1073 | This will act as if the timer timed out and restart it again if it is |
1074 | repeating. The exact semantics are: |
1074 | repeating. The exact semantics are: |
1075 | .Sp |
1075 | .Sp |
|
|
1076 | If the timer is pending, its pending status is cleared. |
|
|
1077 | .Sp |
1076 | If the timer is started but nonrepeating, stop it. |
1078 | If the timer is started but nonrepeating, stop it (as if it timed out). |
1077 | .Sp |
1079 | .Sp |
1078 | If the timer is repeating, either start it if necessary (with the repeat |
1080 | If the timer is repeating, either start it if necessary (with the |
1079 | value), 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 |
1081 | This sounds a bit complicated, but here is a useful and typical |
1083 | This sounds a bit complicated, but here is a useful and typical |
1082 | example: Imagine you have a tcp connection and you want a so-called |
1084 | example: Imagine you have a tcp connection and you want a so-called idle |
1083 | idle timeout, that is, you want to be called when there have been, |
1085 | timeout, that is, you want to be called when there have been, say, 60 |
1084 | say, 60 seconds of inactivity on the socket. The easiest way to do |
1086 | seconds of inactivity on the socket. The easiest way to do this is to |
1085 | this 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 |
1087 | configure 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 |
1087 | you go into an idle state where you do not expect data to travel on the |
1089 | you go into an idle state where you do not expect data to travel on the |
1088 | socket, you can stop the timer, and again will automatically restart it if |
1090 | socket, you can \f(CW\*(C`ev_timer_stop\*(C'\fR the timer, and \f(CW\*(C`ev_timer_again\*(C'\fR will |
1089 | need be. |
1091 | automatically restart it if need be. |
1090 | .Sp |
1092 | .Sp |
1091 | You can also ignore the \f(CW\*(C`after\*(C'\fR value and \f(CW\*(C`ev_timer_start\*(C'\fR altogether |
1093 | That means you can ignore the \f(CW\*(C`after\*(C'\fR value and \f(CW\*(C`ev_timer_start\*(C'\fR |
1092 | and only ever use the \f(CW\*(C`repeat\*(C'\fR value: |
1094 | altogether 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 |
1105 | This is more efficient then stopping/starting the timer eahc time you want |
1107 | This is more slightly efficient then stopping/starting the timer each time |
1106 | to modify its timeout value. |
1108 | you 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]" |
1109 | The current \f(CW\*(C`repeat\*(C'\fR value. Will be used each time the watcher times out |
1111 | The current \f(CW\*(C`repeat\*(C'\fR value. Will be used each time the watcher times out |
1110 | or \f(CW\*(C`ev_timer_again\*(C'\fR is called and determines the next timeout (if any), |
1112 | or \f(CW\*(C`ev_timer_again\*(C'\fR is called and determines the next timeout (if any), |
1111 | which is also when any modifications are taken into account. |
1113 | which is also when any modifications are taken into account. |