Browse Source

*** empty log message ***

tags/rel-4.33
Marc Alexander Lehmann 10 months ago
parent
commit
a385eacff5
3 changed files with 47 additions and 32 deletions
  1. +4
    -1
      Changes
  2. +26
    -24
      ev++.h
  3. +17
    -7
      ev.3

+ 4
- 1
Changes View File

@@ -11,13 +11,16 @@ TODO: maybe allow events = 0 for io watchers
members in io watchers when the wqatcher was stopped
(found by b_jonas).
- new ev_io_modify mutator which changes only the events member,
which can be faster.
which can be faster. also added ev::io::set (int events) method
to ev++.h.
- officially allow a zero events mask for io watchers. this should
work with older libev versions as well but was not officially
allowed before.
- do not wake up every minute when timerfd is used to detect timejumps.
- support a lot more "uncommon" compile time configurations,
such as ev_embed enabled but ev_timer disabled.
- use a start/stop wrapper class to reduce code duplication in
ev++.h and make it needlessly more c++-y.
- the linux aio backend is no longer compiled in by default.
- update to libecb version 0x00010008.



+ 26
- 24
ev++.h View File

@@ -421,6 +421,24 @@ namespace ev {
template<class ev_watcher, class watcher>
struct base : ev_watcher
{
// scoped pause/unpause of a watcher
struct freeze_guard
{
watcher &w;
bool active;

freeze_guard (watcher *self) EV_NOEXCEPT
: w (*self), active (w.is_active ())
{
if (active) w.stop ();
}

~freeze_guard ()
{
if (active) w.start ();
}
};

#if EV_MULTIPLICITY
EV_PX;

@@ -614,18 +632,14 @@ namespace ev {
EV_BEGIN_WATCHER (io, io)
void set (int fd, int events) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_io_set (static_cast<ev_io *>(this), fd, events);
if (active) start ();
}

void set (int events) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_io_modify (static_cast<ev_io *>(this), events);
if (active) start ();
}

void start (int fd, int events) EV_NOEXCEPT
@@ -638,10 +652,8 @@ namespace ev {
EV_BEGIN_WATCHER (timer, timer)
void set (ev_tstamp after, ev_tstamp repeat = 0.) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_timer_set (static_cast<ev_timer *>(this), after, repeat);
if (active) start ();
}

void start (ev_tstamp after, ev_tstamp repeat = 0.) EV_NOEXCEPT
@@ -665,10 +677,8 @@ namespace ev {
EV_BEGIN_WATCHER (periodic, periodic)
void set (ev_tstamp at, ev_tstamp interval = 0.) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_periodic_set (static_cast<ev_periodic *>(this), at, interval, 0);
if (active) start ();
}

void start (ev_tstamp at, ev_tstamp interval = 0.) EV_NOEXCEPT
@@ -688,10 +698,8 @@ namespace ev {
EV_BEGIN_WATCHER (sig, signal)
void set (int signum) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_signal_set (static_cast<ev_signal *>(this), signum);
if (active) start ();
}

void start (int signum) EV_NOEXCEPT
@@ -706,10 +714,8 @@ namespace ev {
EV_BEGIN_WATCHER (child, child)
void set (int pid, int trace = 0) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_child_set (static_cast<ev_child *>(this), pid, trace);
if (active) start ();
}

void start (int pid, int trace = 0) EV_NOEXCEPT
@@ -724,10 +730,8 @@ namespace ev {
EV_BEGIN_WATCHER (stat, stat)
void set (const char *path, ev_tstamp interval = 0.) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_stat_set (static_cast<ev_stat *>(this), path, interval);
if (active) start ();
}

void start (const char *path, ev_tstamp interval = 0.) EV_NOEXCEPT
@@ -766,10 +770,8 @@ namespace ev {
EV_BEGIN_WATCHER (embed, embed)
void set_embed (struct ev_loop *embedded_loop) EV_NOEXCEPT
{
int active = is_active ();
if (active) stop ();
freeze_guard freeze (this);
ev_embed_set (static_cast<ev_embed *>(this), embedded_loop);
if (active) start ();
}

void start (struct ev_loop *embedded_loop) EV_NOEXCEPT


+ 17
- 7
ev.3 View File

@@ -1351,8 +1351,9 @@ with a watcher-specific start function (\f(CW\*(C`ev_TYPE_start (loop, watcher
corresponding stop function (\f(CW\*(C`ev_TYPE_stop (loop, watcher *)\*(C'\fR.
.PP
As long as your watcher is active (has been started but not stopped) you
must not touch the values stored in it. Most specifically you must never
reinitialise it or call its \f(CW\*(C`ev_TYPE_set\*(C'\fR macro.
must not touch the values stored in it except when explicitly documented
otherwise. Most specifically you must never reinitialise it or call its
\&\f(CW\*(C`ev_TYPE_set\*(C'\fR macro.
.PP
Each and every callback receives the event loop pointer as first, the
registered watcher structure as second, and a bitset of received events as
@@ -1955,8 +1956,14 @@ opportunity for a DoS attack.
.IX Item "ev_io_set (ev_io *, int fd, int events)"
.PD
Configures an \f(CW\*(C`ev_io\*(C'\fR watcher. The \f(CW\*(C`fd\*(C'\fR is the file descriptor to
receive events for and \f(CW\*(C`events\*(C'\fR is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or
\&\f(CW\*(C`EV_READ | EV_WRITE\*(C'\fR, to express the desire to receive the given events.
receive events for and \f(CW\*(C`events\*(C'\fR is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR, both
\&\f(CW\*(C`EV_READ | EV_WRITE\*(C'\fR or \f(CW0\fR, to express the desire to receive the given
events.
.Sp
Note that setting the \f(CW\*(C`events\*(C'\fR to \f(CW0\fR and starting the watcher is
supported, but not specially optimized \- if your program sometimes happens
to generate this combination this is fine, but if it is easy to avoid
starting an io watcher watching for no events you should do so.
.IP "ev_io_modify (ev_io *, int events)" 4
.IX Item "ev_io_modify (ev_io *, int events)"
Similar to \f(CW\*(C`ev_io_set\*(C'\fR, but only changes the event mask. Using this might
@@ -1970,9 +1977,9 @@ must not modify this member even when the watcher is stopped \- always use
\&\f(CW\*(C`ev_io_set\*(C'\fR for that.
.IP "int events [no\-modify]" 4
.IX Item "int events [no-modify]"
The set of events being watched, among other flags. This field is a
bit set \- to test for \f(CW\*(C`EV_READ\*(C'\fR, use \f(CW\*(C`w\->events & EV_READ\*(C'\fR, and
similarly for \f(CW\*(C`EV_WRITE\*(C'\fR.
The set of events the fd is being watched for, among other flags. Remember
that this is a bit set \- to test for \f(CW\*(C`EV_READ\*(C'\fR, use \f(CW\*(C`w\->events &
EV_READ\*(C'\fR, and similarly for \f(CW\*(C`EV_WRITE\*(C'\fR.
.Sp
As with \f(CW\*(C`fd\*(C'\fR, you must not modify this member even when the watcher is
stopped, always use \f(CW\*(C`ev_io_set\*(C'\fR or \f(CW\*(C`ev_io_modify\*(C'\fR for that.
@@ -4413,6 +4420,9 @@ method.
.Sp
For \f(CW\*(C`ev::embed\*(C'\fR watchers this method is called \f(CW\*(C`set_embed\*(C'\fR, to avoid
clashing with the \f(CW\*(C`set (loop)\*(C'\fR method.
.Sp
For \f(CW\*(C`ev::io\*(C'\fR watchers there is an additional \f(CW\*(C`set\*(C'\fR method that acepts a
new event mask only, and internally calls \f(CW\*(C`ev_io_modfify\*(C'\fR.
.IP "w\->start ()" 4
.IX Item "w->start ()"
Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the


Loading…
Cancel
Save