mirror of /home/gitosis/repositories/libev.git
many fixes to event emulation
parent
2a9f754117
commit
2180940ae4
30
ev.3
30
ev.3
|
@ -129,7 +129,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title ""<STANDARD INPUT>" 1"
|
||||
.TH "<STANDARD INPUT>" 1 "2007-11-28" "perl v5.8.8" "User Contributed Perl Documentation"
|
||||
.TH "<STANDARD INPUT>" 1 "2007-11-29" "perl v5.8.8" "User Contributed Perl Documentation"
|
||||
.SH "NAME"
|
||||
libev \- a high performance full\-featured event loop written in C
|
||||
.SH "SYNOPSIS"
|
||||
|
@ -1073,23 +1073,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:
|
||||
.Sp
|
||||
If the timer is started but nonrepeating, stop it.
|
||||
If the timer is pending, its pending status is cleared.
|
||||
.Sp
|
||||
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).
|
||||
.Sp
|
||||
If the timer is repeating, either start it if necessary (with the
|
||||
\&\f(CW\*(C`repeat\*(C'\fR value), or reset the running timer to the \f(CW\*(C`repeat\*(C'\fR value.
|
||||
.Sp
|
||||
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 \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
|
||||
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 \f(CW\*(C`ev_timer\*(C'\fR with a \f(CW\*(C`repeat\*(C'\fR value of \f(CW60\fR and then call
|
||||
\&\f(CW\*(C`ev_timer_again\*(C'\fR 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 \f(CW\*(C`ev_timer_stop\*(C'\fR the timer, and \f(CW\*(C`ev_timer_again\*(C'\fR will
|
||||
automatically restart it if need be.
|
||||
.Sp
|
||||
You can also ignore the \f(CW\*(C`after\*(C'\fR value and \f(CW\*(C`ev_timer_start\*(C'\fR altogether
|
||||
and only ever use the \f(CW\*(C`repeat\*(C'\fR value:
|
||||
That means you can ignore the \f(CW\*(C`after\*(C'\fR value and \f(CW\*(C`ev_timer_start\*(C'\fR
|
||||
altogether and only ever use the \f(CW\*(C`repeat\*(C'\fR value and \f(CW\*(C`ev_timer_again\*(C'\fR:
|
||||
.Sp
|
||||
.Vb 8
|
||||
\& ev_timer_init (timer, callback, 0., 5.);
|
||||
|
@ -1102,8 +1104,8 @@ and only ever use the \f(CW\*(C`repeat\*(C'\fR value:
|
|||
\& ev_timer_again (loop, timer);
|
||||
.Ve
|
||||
.Sp
|
||||
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.
|
||||
.IP "ev_tstamp repeat [read\-write]" 4
|
||||
.IX Item "ev_tstamp repeat [read-write]"
|
||||
The current \f(CW\*(C`repeat\*(C'\fR value. Will be used each time the watcher times out
|
||||
|
|
29
ev.html
29
ev.html
|
@ -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>
|
||||
|
|
28
ev.pod
28
ev.pod
|
@ -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]
|
||||
|
||||
|
|
23
event.c
23
event.c
|
@ -160,13 +160,8 @@ x_cb_io (EV_P_ struct ev_io *w, int revents)
|
|||
{
|
||||
struct event *ev = (struct event *)(((char *)w) - offsetof (struct event, iosig.io));
|
||||
|
||||
if (revents & EV_ERROR)
|
||||
if ((revents & EV_ERROR) || !(ev->ev_events & EV_PERSIST))
|
||||
event_del (ev);
|
||||
else if (!(ev->ev_events & EV_PERSIST) && ev_is_active (w))
|
||||
{
|
||||
ev_io_stop (EV_A_ w);
|
||||
ev->ev_flags &= ~EVLIST_INSERTED;
|
||||
}
|
||||
|
||||
x_cb (ev, revents);
|
||||
}
|
||||
|
@ -237,8 +232,10 @@ int event_add (struct event *ev, struct timeval *tv)
|
|||
ev->ev_flags |= EVLIST_TIMEOUT;
|
||||
}
|
||||
else
|
||||
if (ev_is_active (&ev->to))
|
||||
{
|
||||
ev_timer_stop (EV_A_ &ev->to);
|
||||
ev->ev_flags &= ~EVLIST_TIMEOUT;
|
||||
}
|
||||
|
||||
ev->ev_flags |= EVLIST_ACTIVE;
|
||||
|
||||
|
@ -250,17 +247,9 @@ int event_del (struct event *ev)
|
|||
dLOOPev;
|
||||
|
||||
if (ev->ev_events & EV_SIGNAL)
|
||||
{
|
||||
/* sig */
|
||||
if (ev_is_active (&ev->iosig.sig))
|
||||
ev_signal_stop (EV_A_ &ev->iosig.sig);
|
||||
}
|
||||
ev_signal_stop (EV_A_ &ev->iosig.sig);
|
||||
else if (ev->ev_events & (EV_READ | EV_WRITE))
|
||||
{
|
||||
/* io */
|
||||
if (ev_is_active (&ev->iosig.io))
|
||||
ev_io_stop (EV_A_ &ev->iosig.io);
|
||||
}
|
||||
ev_io_stop (EV_A_ &ev->iosig.io);
|
||||
|
||||
if (ev_is_active (&ev->to))
|
||||
ev_timer_stop (EV_A_ &ev->to);
|
||||
|
|
Loading…
Reference in New Issue