summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Alexander Lehmann <libev@schmorp.de>2020-01-22 01:50:42 +0000
committerMarc Alexander Lehmann <libev@schmorp.de>2020-01-22 01:50:42 +0000
commit0adc8e592f7512926996e885176a1bef6a59d938 (patch)
tree6e2f459801f5ab3eb7462310083605fec62e91d5
parentbfe311f117a256705c8701781792f1598cdebd45 (diff)
downloadlibev-0adc8e592f7512926996e885176a1bef6a59d938.tar.gz
libev-0adc8e592f7512926996e885176a1bef6a59d938.zip
*** empty log message ***
-rw-r--r--Changes3
-rw-r--r--ev++.h12
-rw-r--r--ev.h1
-rw-r--r--ev.pod32
4 files changed, 34 insertions, 14 deletions
diff --git a/Changes b/Changes
index 63af668..394420a 100644
--- a/Changes
+++ b/Changes
@@ -3,8 +3,11 @@ Revision history for libev, a high-performance and full-featured event loop.
TODO: revisit 59.x timer in the light of modern powersaving
TODO: ^ maybe just increase it when timerfd, modern linux only thing that counts?
TODO: document EV_TSTAMP_T
+TODO: for next ABI/API change, consider moving EV__IOFDSSET into io->fd instead and provide a getter.
TODO: add ev_io_set_events, or ev_io_modify, or ev_io_change, or..., without IOFDSET
+TODO: fix documentation of read-only] [read-write] and so on
+TODO: maybe allow events = 0 for io watchers
- the 4.31 timerfd code wrongly changes the priority of the signal
fd watcher, which is usually harmless unless signal fds are
also used (found via cpan tester service).
diff --git a/ev++.h b/ev++.h
index 0e1b60d..5832219 100644
--- a/ev++.h
+++ b/ev++.h
@@ -564,13 +564,13 @@ namespace ev {
#if EV_MULTIPLICITY
#define EV_CONSTRUCT(cppstem,cstem) \
- (EV_PX = get_default_loop ()) EV_NOEXCEPT \
+ (EV_PX = get_default_loop ()) EV_NOEXCEPT \
: base<ev_ ## cstem, cppstem> (EV_A) \
{ \
}
#else
#define EV_CONSTRUCT(cppstem,cstem) \
- () EV_NOEXCEPT \
+ () EV_NOEXCEPT \
{ \
}
#endif
@@ -581,19 +581,19 @@ namespace ev {
\
struct cppstem : base<ev_ ## cstem, cppstem> \
{ \
- void start () EV_NOEXCEPT \
+ void start () EV_NOEXCEPT \
{ \
ev_ ## cstem ## _start (EV_A_ static_cast<ev_ ## cstem *>(this)); \
} \
\
- void stop () EV_NOEXCEPT \
+ void stop () EV_NOEXCEPT \
{ \
ev_ ## cstem ## _stop (EV_A_ static_cast<ev_ ## cstem *>(this)); \
} \
\
cppstem EV_CONSTRUCT(cppstem,cstem) \
\
- ~cppstem () EV_NOEXCEPT \
+ ~cppstem () EV_NOEXCEPT \
{ \
stop (); \
} \
@@ -624,7 +624,7 @@ namespace ev {
{
int active = is_active ();
if (active) stop ();
- ev_io_set (static_cast<ev_io *>(this), fd, events);
+ ev_io_modify (static_cast<ev_io *>(this), events);
if (active) start ();
}
diff --git a/ev.h b/ev.h
index 4a57d73..65c11e0 100644
--- a/ev.h
+++ b/ev.h
@@ -694,6 +694,7 @@ EV_API_DECL void ev_resume (EV_P) EV_NOEXCEPT;
ev_set_cb ((ev), cb_); \
} while (0)
+#define ev_io_modify(ev,events_) do { (ev)->events = (ev)->events & EV__IOMASK | (events_); } while (0)
#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0)
#define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0)
#define ev_periodic_set(ev,ofs_,ival_,rcb_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); } while (0)
diff --git a/ev.pod b/ev.pod
index 5d60ed2..a88d811 100644
--- a/ev.pod
+++ b/ev.pod
@@ -1650,15 +1650,17 @@ This section describes each watcher in detail, but will not repeat
information given in the last section. Any initialisation/set macros,
functions and members specific to the watcher type are explained.
-Members are additionally marked with either I<[read-only]>, meaning that,
-while the watcher is active, you can look at the member and expect some
-sensible content, but you must not modify it (you can modify it while the
-watcher is stopped to your hearts content), or I<[read-write]>, which
+Most members are additionally marked with either I<[read-only]>, meaning
+that, while the watcher is active, you can look at the member and expect
+some sensible content, but you must not modify it (you can modify it while
+the watcher is stopped to your hearts content), or I<[read-write]>, which
means you can expect it to have some sensible content while the watcher
is active, but you can also modify it. Modifying it may not do something
sensible or take immediate effect (or do anything at all), but libev will
not crash or malfunction in any way.
+In any case, the documentation for each member will explain what the
+effects are, and if there are any additional access restrictions.
=head2 C<ev_io> - is this file descriptor readable or writable?
@@ -1831,13 +1833,27 @@ Configures an C<ev_io> watcher. The C<fd> is the file descriptor to
receive events for and C<events> is either C<EV_READ>, C<EV_WRITE> or
C<EV_READ | EV_WRITE>, to express the desire to receive the given events.
-=item int fd [read-only]
+=item ev_io_modify (ev_io *, int events)
-The file descriptor being watched.
+Similar to C<ev_io_set>, but only changes the event mask. Using this might
+be faster with some backends, as libev can assume that the C<fd> still
+refers to the same underlying file description, something it cannot do
+when using C<ev_io_set>.
-=item int events [read-only]
+=item int fd [no-modify]
-The events being watched.
+The file descriptor being watched. While it can be read at any time, you
+must not modify this member even when the watcher is stopped - always use
+C<ev_io_set> for that.
+
+=item int events [no-modify]
+
+The set of events being watched, among other flags. This field is a
+bit set - to test for C<EV_READ>, use C<< w->events & EV_READ >>, and
+similarly for C<EV_WRITE>.
+
+As with C<fd>, you must not modify this member even when the watcher is
+stopped, always use C<ev_io_set> or C<ev_io_modify> for that.
=back