Browse Source

*** empty log message ***

master rel-4.25
Marc Alexander Lehmann 2 years ago
parent
commit
31ca40b7a1
2 changed files with 41 additions and 21 deletions
  1. +1
    -1
      Changes
  2. +40
    -20
      ev.3

+ 1
- 1
Changes View File

@ -2,7 +2,7 @@ Revision history for libev, a high-performance and full-featured event loop.
4.25 Fri Dec 21 07:49:20 CET 2018
- INCOMPATIBLE CHANGE: EV_THROW was renamed to EV_NOEXCEPT
(EV_THROW sitll provided) and now uses noexcept on C++11 or newer.
(EV_THROW still provided) and now uses noexcept on C++11 or newer.
- move the darwin select workaround highe rin ev.c, as newer versions of
darwin managed to break their broken select even more.
- ANDROID => __ANDROID__ (reported by enh@google.com).


+ 40
- 20
ev.3 View File

@ -133,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "LIBEV 3"
.TH LIBEV 3 "2017-11-14" "libev-4.24" "libev - high performance full featured event loop"
.TH LIBEV 3 "2018-12-21" "libev-4.25" "libev - high performance full featured event loop"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@ -2253,11 +2253,11 @@ deterministic behaviour in this case (you can do nothing against
.IP "ev_timer_set (ev_timer *, ev_tstamp after, ev_tstamp repeat)" 4
.IX Item "ev_timer_set (ev_timer *, ev_tstamp after, ev_tstamp repeat)"
.PD
Configure the timer to trigger after \f(CW\*(C`after\*(C'\fR seconds. If \f(CW\*(C`repeat\*(C'\fR
is \f(CW0.\fR, then it will automatically be stopped once the timeout is
reached. If it is positive, then the timer will automatically be
configured to trigger again \f(CW\*(C`repeat\*(C'\fR seconds later, again, and again,
until stopped manually.
Configure the timer to trigger after \f(CW\*(C`after\*(C'\fR seconds (fractional and
negative values are supported). If \f(CW\*(C`repeat\*(C'\fR is \f(CW0.\fR, then it will
automatically be stopped once the timeout is reached. If it is positive,
then the timer will automatically be configured to trigger again \f(CW\*(C`repeat\*(C'\fR
seconds later, again, and again, until stopped manually.
.Sp
The timer itself will do a best-effort at avoiding drift, that is, if
you configure a timer to trigger every 10 seconds, then it will normally
@ -2364,8 +2364,8 @@ it, as it uses a relative timeout).
.PP
\&\f(CW\*(C`ev_periodic\*(C'\fR watchers can also be used to implement vastly more complex
timers, such as triggering an event on each \*(L"midnight, local time\*(R", or
other complicated rules. This cannot be done with \f(CW\*(C`ev_timer\*(C'\fR watchers, as
those cannot react to time jumps.
other complicated rules. This cannot easily be done with \f(CW\*(C`ev_timer\*(C'\fR
watchers, as those cannot react to time jumps.
.PP
As with timers, the callback is guaranteed to be invoked only when the
point in time where it is supposed to trigger has passed. If multiple
@ -2464,10 +2464,30 @@ might be called at other times, too.
equal to the passed \f(CI\*(C`now\*(C'\fI value\fR.
.Sp
This can be used to create very complex timers, such as a timer that
triggers on \*(L"next midnight, local time\*(R". To do this, you would calculate the
next midnight after \f(CW\*(C`now\*(C'\fR and return the timestamp value for this. How
you do this is, again, up to you (but it is not trivial, which is the main
reason I omitted it as an example).
triggers on \*(L"next midnight, local time\*(R". To do this, you would calculate
the next midnight after \f(CW\*(C`now\*(C'\fR and return the timestamp value for
this. Here is a (completely untested, no error checking) example on how to
do this:
.Sp
.Vb 1
\& #include <time.h>
\&
\& static ev_tstamp
\& my_rescheduler (ev_periodic *w, ev_tstamp now)
\& {
\& time_t tnow = (time_t)now;
\& struct tm tm;
\& localtime_r (&tnow, &tm);
\&
\& tm.tm_sec = tm.tm_min = tm.tm_hour = 0; // midnight current day
\& ++tm.tm_mday; // midnight next day
\&
\& return mktime (&tm);
\& }
.Ve
.Sp
Note: this code might run into trouble on days that have more then two
midnights (beginning and end).
.RE
.RS 4
.RE
@ -3647,8 +3667,8 @@ notification, and the callback being invoked.
.SH "OTHER FUNCTIONS"
.IX Header "OTHER FUNCTIONS"
There are some other functions of possible interest. Described. Here. Now.
.IP "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)" 4
.IX Item "ev_once (loop, int fd, int events, ev_tstamp timeout, callback)"
.IP "ev_once (loop, int fd, int events, ev_tstamp timeout, callback, arg)" 4
.IX Item "ev_once (loop, int fd, int events, ev_tstamp timeout, callback, arg)"
This function combines a simple timer and an I/O watcher, calls your
callback on whichever event happens first and automatically stops both
watchers. This is useful if you want to wait for a single event on an fd
@ -4108,15 +4128,15 @@ libev sources can be compiled as \*(C+. Therefore, code that uses the C \s-1API\
will work fine.
.PP
Proper exception specifications might have to be added to callbacks passed
to libev: exceptions may be thrown only from watcher callbacks, all
other callbacks (allocator, syserr, loop acquire/release and periodic
reschedule callbacks) must not throw exceptions, and might need a \f(CW\*(C`throw
()\*(C'\fR specification. If you have code that needs to be compiled as both C
and \*(C+ you can use the \f(CW\*(C`EV_THROW\*(C'\fR macro for this:
to libev: exceptions may be thrown only from watcher callbacks, all other
callbacks (allocator, syserr, loop acquire/release and periodic reschedule
callbacks) must not throw exceptions, and might need a \f(CW\*(C`noexcept\*(C'\fR
specification. If you have code that needs to be compiled as both C and
\&\*(C+ you can use the \f(CW\*(C`EV_NOEXCEPT\*(C'\fR macro for this:
.PP
.Vb 6
\& static void
\& fatal_error (const char *msg) EV_THROW
\& fatal_error (const char *msg) EV_NOEXCEPT
\& {
\& perror (msg);
\& abort ();


Loading…
Cancel
Save