summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-12-09 19:42:57 +0000
committerroot <root>2007-12-09 19:42:57 +0000
commit9df49634f11f561ad9b5669124a4f2bd7179a559 (patch)
treee9b29494d8bc1b1b82b86908a7e2e1b2dede78fd
parent5466167e0504f6fd929074dda89e770d4abfd3c3 (diff)
*** empty log message ***
-rw-r--r--ev.337
-rw-r--r--ev.h3
-rw-r--r--ev.html8
-rw-r--r--ev.pod7
4 files changed, 36 insertions, 19 deletions
diff --git a/ev.3 b/ev.3
index d7dbe2e..963bdfd 100644
--- a/ev.3
+++ b/ev.3
@@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title ""<STANDARD INPUT>" 1"
-.TH "<STANDARD INPUT>" 1 "2007-12-08" "perl v5.8.8" "User Contributed Perl Documentation"
+.TH "<STANDARD INPUT>" 1 "2007-12-09" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
libev \- a high performance full\-featured event loop written in C
.SH "SYNOPSIS"
@@ -1237,11 +1237,11 @@ to trigger \*(L"at\*(R" some specific point in time. For example, if you tell a
periodic watcher to trigger in 10 seconds (by specifiying e.g. \f(CW\*(C`ev_now ()
+ 10.\*(C'\fR) and then reset your system clock to the last year, then it will
take a year to trigger the event (unlike an \f(CW\*(C`ev_timer\*(C'\fR, which would trigger
-roughly 10 seconds later and of course not if you reset your system time
-again).
+roughly 10 seconds later).
.PP
They can also be used to implement vastly more complex timers, such as
-triggering an event on eahc midnight, local time.
+triggering an event on each midnight, local time or other, complicated,
+rules.
.PP
As with timers, the callback is guarenteed to be invoked only when the
time (\f(CW\*(C`at\*(C'\fR) has been passed, but if multiple periodic timers become ready
@@ -1255,17 +1255,17 @@ during the same loop iteration then order of execution is undefined.
Lots of arguments, lets sort it out... There are basically three modes of
operation, and we will explain them from simplest to complex:
.RS 4
-.IP "* absolute timer (interval = reschedule_cb = 0)" 4
-.IX Item "absolute timer (interval = reschedule_cb = 0)"
+.IP "* absolute timer (at = time, interval = reschedule_cb = 0)" 4
+.IX Item "absolute timer (at = time, interval = reschedule_cb = 0)"
In this configuration the watcher triggers an event at the wallclock time
\&\f(CW\*(C`at\*(C'\fR and doesn't repeat. It will not adjust when a time jump occurs,
that is, if it is to be run at January 1st 2011 then it will run when the
system time reaches or surpasses this time.
-.IP "* non-repeating interval timer (interval > 0, reschedule_cb = 0)" 4
-.IX Item "non-repeating interval timer (interval > 0, reschedule_cb = 0)"
+.IP "* non-repeating interval timer (at = offset, interval > 0, reschedule_cb = 0)" 4
+.IX Item "non-repeating interval timer (at = offset, interval > 0, reschedule_cb = 0)"
In this mode the watcher will always be scheduled to time out at the next
-\&\f(CW\*(C`at + N * interval\*(C'\fR time (for some integer N) and then repeat, regardless
-of any time jumps.
+\&\f(CW\*(C`at + N * interval\*(C'\fR time (for some integer N, which can also be negative)
+and then repeat, regardless of any time jumps.
.Sp
This can be used to create timers that do not drift with respect to system
time:
@@ -1282,8 +1282,12 @@ by 3600.
Another way to think about it (for the mathematically inclined) is that
\&\f(CW\*(C`ev_periodic\*(C'\fR will try to run the callback in this mode at the next possible
time where \f(CW\*(C`time = at (mod interval)\*(C'\fR, regardless of any time jumps.
-.IP "* manual reschedule mode (reschedule_cb = callback)" 4
-.IX Item "manual reschedule mode (reschedule_cb = callback)"
+.Sp
+For numerical stability it is preferable that the \f(CW\*(C`at\*(C'\fR value is near
+\&\f(CW\*(C`ev_now ()\*(C'\fR (the current time), but there is no range requirement for
+this value.
+.IP "* manual reschedule mode (at and interval ignored, reschedule_cb = callback)" 4
+.IX Item "manual reschedule mode (at and interval ignored, reschedule_cb = callback)"
In this mode the values for \f(CW\*(C`interval\*(C'\fR and \f(CW\*(C`at\*(C'\fR are both being
ignored. Instead, each time the periodic watcher gets scheduled, the
reschedule callback will be called with the watcher as first, and the
@@ -1292,7 +1296,7 @@ current time as second argument.
\&\s-1NOTE:\s0 \fIThis callback \s-1MUST\s0 \s-1NOT\s0 stop or destroy any periodic watcher,
ever, or make any event loop modifications\fR. If you need to stop it,
return \f(CW\*(C`now + 1e30\*(C'\fR (or so, fudge fudge) and stop it afterwards (e.g. by
-starting a prepare watcher).
+starting an \f(CW\*(C`ev_prepare\*(C'\fR watcher, which is legal).
.Sp
Its prototype is \f(CW\*(C`ev_tstamp (*reschedule_cb)(struct ev_periodic *w,
ev_tstamp now)\*(C'\fR, e.g.:
@@ -1326,6 +1330,13 @@ Simply stops and restarts the periodic watcher again. This is only useful
when you changed some parameters or the reschedule callback would return
a different time than the last time it was called (e.g. in a crond like
program when the crontabs have changed).
+.IP "ev_tstamp offset [read\-write]" 4
+.IX Item "ev_tstamp offset [read-write]"
+When repeating, this contains the offset value, otherwise this is the
+absolute point in time (the \f(CW\*(C`at\*(C'\fR value passed to \f(CW\*(C`ev_periodic_set\*(C'\fR).
+.Sp
+Can be modified any time, but changes only take effect when the periodic
+timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called.
.IP "ev_tstamp interval [read\-write]" 4
.IX Item "ev_tstamp interval [read-write]"
The current interval value. Can be modified any time, but changes only
diff --git a/ev.h b/ev.h
index 0652f1b..fa4c6c7 100644
--- a/ev.h
+++ b/ev.h
@@ -195,6 +195,7 @@ typedef struct ev_periodic
{
EV_WATCHER_TIME (ev_periodic)
+ ev_tstamp offset; /* rw */
ev_tstamp interval; /* rw */
ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now); /* rw */
} ev_periodic;
@@ -433,7 +434,7 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0)
#define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0)
-#define ev_periodic_set(ev,at_,ival_,res_) do { (ev)->at = (at_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0)
+#define ev_periodic_set(ev,ofs_,ival_,res_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0)
#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
#define ev_child_set(ev,pid_) do { (ev)->pid = (pid_); } while (0)
#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0)
diff --git a/ev.html b/ev.html
index 308d179..e1af75a 100644
--- a/ev.html
+++ b/ev.html
@@ -6,7 +6,7 @@
<meta name="description" content="Pod documentation for libev" />
<meta name="inputfile" content="&lt;standard input&gt;" />
<meta name="outputfile" content="&lt;standard output&gt;" />
- <meta name="created" content="Sun Dec 9 20:30:11 2007" />
+ <meta name="created" content="Sun Dec 9 20:45:16 2007" />
<meta name="generator" content="Pod::Xhtml 1.57" />
<link rel="stylesheet" href="http://res.tst.eu/pod.css"/></head>
<body>
@@ -187,13 +187,15 @@ you actually want to know.</p>
<dt>int ev_version_major ()</dt>
<dt>int ev_version_minor ()</dt>
<dd>
- <p>You can find out the major and minor version numbers of the library
+ <p>You can find out the major and minor API/ABI version numbers of the library
you linked against by calling the functions <code>ev_version_major</code> and
<code>ev_version_minor</code>. If you want, you can compare against the global
symbols <code>EV_VERSION_MAJOR</code> and <code>EV_VERSION_MINOR</code>, which specify the
version of the library your program was compiled against.</p>
+ <p>These version numbers refer to the API and ABI version of the library, not
+the release version.</p>
<p>Usually, it's a good idea to terminate if the major versions mismatch,
-as this indicates an incompatible change. Minor versions are usually
+as this indicates an incompatible change. Minor versions are usually
compatible to older versions, so a larger minor version alone is usually
not a problem.</p>
<p>Example: Make sure we haven't accidentally been linked against the wrong
diff --git a/ev.pod b/ev.pod
index 3ad52c0..0657b7f 100644
--- a/ev.pod
+++ b/ev.pod
@@ -119,14 +119,17 @@ you actually want to know.
=item int ev_version_minor ()
-You can find out the major and minor version numbers of the library
+You can find out the major and minor API/ABI version numbers of the library
you linked against by calling the functions C<ev_version_major> and
C<ev_version_minor>. If you want, you can compare against the global
symbols C<EV_VERSION_MAJOR> and C<EV_VERSION_MINOR>, which specify the
version of the library your program was compiled against.
+These version numbers refer to the API and ABI version of the library, not
+the release version.
+
Usually, it's a good idea to terminate if the major versions mismatch,
-as this indicates an incompatible change. Minor versions are usually
+as this indicates an incompatible change. Minor versions are usually
compatible to older versions, so a larger minor version alone is usually
not a problem.