summaryrefslogtreecommitdiff
path: root/ev.3
diff options
context:
space:
mode:
Diffstat (limited to 'ev.3')
-rw-r--r--ev.31179
1 files changed, 611 insertions, 568 deletions
diff --git a/ev.3 b/ev.3
index 35e0f2f..bcec311 100644
--- a/ev.3
+++ b/ev.3
@@ -132,7 +132,7 @@
.\" ========================================================================
.\"
.IX Title "LIBEV 3"
-.TH LIBEV 3 "2008-05-22" "libev-3.41" "libev - high perfromance full featured event loop"
+.TH LIBEV 3 "2008-06-09" "libev-3.42" "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
@@ -142,64 +142,64 @@ libev \- a high performance full\-featured event loop written in C
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
-\& #include <ev.h>
+\& #include <ev.h>
.Ve
.Sh "\s-1EXAMPLE\s0 \s-1PROGRAM\s0"
.IX Subsection "EXAMPLE PROGRAM"
.Vb 2
-\& // a single header file is required
-\& #include <ev.h>
-\&
-\& // every watcher type has its own typedef\*(Aqd struct
-\& // with the name ev_<type>
-\& ev_io stdin_watcher;
-\& ev_timer timeout_watcher;
-\&
-\& // all watcher callbacks have a similar signature
-\& // this callback is called when data is readable on stdin
-\& static void
-\& stdin_cb (EV_P_ struct ev_io *w, int revents)
-\& {
-\& puts ("stdin ready");
-\& // for one\-shot events, one must manually stop the watcher
-\& // with its corresponding stop function.
-\& ev_io_stop (EV_A_ w);
-\&
-\& // this causes all nested ev_loop\*(Aqs to stop iterating
-\& ev_unloop (EV_A_ EVUNLOOP_ALL);
-\& }
-\&
-\& // another callback, this time for a time\-out
-\& static void
-\& timeout_cb (EV_P_ struct ev_timer *w, int revents)
-\& {
-\& puts ("timeout");
-\& // this causes the innermost ev_loop to stop iterating
-\& ev_unloop (EV_A_ EVUNLOOP_ONE);
-\& }
-\&
-\& int
-\& main (void)
-\& {
-\& // use the default event loop unless you have special needs
-\& struct ev_loop *loop = ev_default_loop (0);
-\&
-\& // initialise an io watcher, then start it
-\& // this one will watch for stdin to become readable
-\& ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ);
-\& ev_io_start (loop, &stdin_watcher);
-\&
-\& // initialise a timer watcher, then start it
-\& // simple non\-repeating 5.5 second timeout
-\& ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.);
-\& ev_timer_start (loop, &timeout_watcher);
-\&
-\& // now wait for events to arrive
-\& ev_loop (loop, 0);
-\&
-\& // unloop was called, so exit
-\& return 0;
-\& }
+\& // a single header file is required
+\& #include <ev.h>
+\&
+\& // every watcher type has its own typedef\*(Aqd struct
+\& // with the name ev_<type>
+\& ev_io stdin_watcher;
+\& ev_timer timeout_watcher;
+\&
+\& // all watcher callbacks have a similar signature
+\& // this callback is called when data is readable on stdin
+\& static void
+\& stdin_cb (EV_P_ struct ev_io *w, int revents)
+\& {
+\& puts ("stdin ready");
+\& // for one\-shot events, one must manually stop the watcher
+\& // with its corresponding stop function.
+\& ev_io_stop (EV_A_ w);
+\&
+\& // this causes all nested ev_loop\*(Aqs to stop iterating
+\& ev_unloop (EV_A_ EVUNLOOP_ALL);
+\& }
+\&
+\& // another callback, this time for a time\-out
+\& static void
+\& timeout_cb (EV_P_ struct ev_timer *w, int revents)
+\& {
+\& puts ("timeout");
+\& // this causes the innermost ev_loop to stop iterating
+\& ev_unloop (EV_A_ EVUNLOOP_ONE);
+\& }
+\&
+\& int
+\& main (void)
+\& {
+\& // use the default event loop unless you have special needs
+\& struct ev_loop *loop = ev_default_loop (0);
+\&
+\& // initialise an io watcher, then start it
+\& // this one will watch for stdin to become readable
+\& ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ);
+\& ev_io_start (loop, &stdin_watcher);
+\&
+\& // initialise a timer watcher, then start it
+\& // simple non\-repeating 5.5 second timeout
+\& ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.);
+\& ev_timer_start (loop, &timeout_watcher);
+\&
+\& // now wait for events to arrive
+\& ev_loop (loop, 0);
+\&
+\& // unloop was called, so exit
+\& return 0;
+\& }
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
@@ -251,7 +251,7 @@ Libev represents time as a single floating point number, representing the
the beginning of 1970, details are complicated, don't ask). This type is
called \f(CW\*(C`ev_tstamp\*(C'\fR, which is what you should use too. It usually aliases
to the \f(CW\*(C`double\*(C'\fR type in C, and when you need to do any calculations on
-it, you should treat it as some floatingpoint value. Unlike the name
+it, you should treat it as some floating point value. Unlike the name
component \f(CW\*(C`stamp\*(C'\fR might indicate, it is also used for time differences
throughout libev.
.SH "ERROR HANDLING"
@@ -260,7 +260,7 @@ Libev knows three classes of errors: operating system errors, usage errors
and internal errors (bugs).
.PP
When libev catches an operating system error it cannot handle (for example
-a syscall indicating a condition libev cannot fix), it calls the callback
+a system call indicating a condition libev cannot fix), it calls the callback
set via \f(CW\*(C`ev_set_syserr_cb\*(C'\fR, which is supposed to fix the problem or
abort. The default is to print a diagnostic message and to call \f(CW\*(C`abort
()\*(C'\fR.
@@ -286,7 +286,7 @@ you actually want to know.
.IX Item "ev_sleep (ev_tstamp interval)"
Sleep for the given interval: The current thread will be blocked until
either it is interrupted or the given time interval has passed. Basically
-this is a subsecond-resolution \f(CW\*(C`sleep ()\*(C'\fR.
+this is a sub-second-resolution \f(CW\*(C`sleep ()\*(C'\fR.
.IP "int ev_version_major ()" 4
.IX Item "int ev_version_major ()"
.PD 0
@@ -311,9 +311,9 @@ Example: Make sure we haven't accidentally been linked against the wrong
version.
.Sp
.Vb 3
-\& assert (("libev version mismatch",
-\& ev_version_major () == EV_VERSION_MAJOR
-\& && ev_version_minor () >= EV_VERSION_MINOR));
+\& assert (("libev version mismatch",
+\& ev_version_major () == EV_VERSION_MAJOR
+\& && ev_version_minor () >= EV_VERSION_MINOR));
.Ve
.IP "unsigned int ev_supported_backends ()" 4
.IX Item "unsigned int ev_supported_backends ()"
@@ -326,15 +326,15 @@ Example: make sure we have the epoll method, because yeah this is cool and
a must have and can we have a torrent of it please!!!11
.Sp
.Vb 2
-\& assert (("sorry, no epoll, no sex",
-\& ev_supported_backends () & EVBACKEND_EPOLL));
+\& assert (("sorry, no epoll, no sex",
+\& ev_supported_backends () & EVBACKEND_EPOLL));
.Ve
.IP "unsigned int ev_recommended_backends ()" 4
.IX Item "unsigned int ev_recommended_backends ()"
Return the set of all backends compiled into this binary of libev and also
recommended for this platform. This set is often smaller than the one
returned by \f(CW\*(C`ev_supported_backends\*(C'\fR, as for example kqueue is broken on
-most BSDs and will not be autodetected unless you explicitly request it
+most BSDs and will not be auto-detected unless you explicitly request it
(assuming you know what you are doing). This is the set of backends that
libev will probe for if you specify no backends explicitly.
.IP "unsigned int ev_embeddable_backends ()" 4
@@ -385,10 +385,10 @@ retries (example requires a standards-compliant \f(CW\*(C`realloc\*(C'\fR).
.Ve
.IP "ev_set_syserr_cb (void (*cb)(const char *msg));" 4
.IX Item "ev_set_syserr_cb (void (*cb)(const char *msg));"
-Set the callback function to call on a retryable syscall error (such
+Set the callback function to call on a retryable system call error (such
as failed select, poll, epoll_wait). The message is a printable string
indicating the system call or subsystem causing the problem. If this
-callback is set, then libev will expect it to remedy the sitution, no
+callback is set, then libev will expect it to remedy the situation, no
matter what, when it returns. That is, libev will generally retry the
requested operation, or, if the condition doesn't go away, do bad stuff
(such as abort).
@@ -427,7 +427,7 @@ as loops cannot bes hared easily between threads anyway).
.Sp
The default loop is the only loop that can handle \f(CW\*(C`ev_signal\*(C'\fR and
\&\f(CW\*(C`ev_child\*(C'\fR watchers, and to do this, it always registers a handler
-for \f(CW\*(C`SIGCHLD\*(C'\fR. If this is a problem for your app you can either
+for \f(CW\*(C`SIGCHLD\*(C'\fR. If this is a problem for your application you can either
create a dynamic loop with \f(CW\*(C`ev_loop_new\*(C'\fR that doesn't do that, or you
can simply overwrite the \f(CW\*(C`SIGCHLD\*(C'\fR signal handler \fIafter\fR calling
\&\f(CW\*(C`ev_default_init\*(C'\fR.
@@ -445,7 +445,7 @@ thing, believe me).
.ie n .IP """EVFLAG_NOENV""" 4
.el .IP "\f(CWEVFLAG_NOENV\fR" 4
.IX Item "EVFLAG_NOENV"
-If this flag bit is ored into the flag value (or the program runs setuid
+If this flag bit is or'ed into the flag value (or the program runs setuid
or setgid) then libev will \fInot\fR look at the environment variable
\&\f(CW\*(C`LIBEV_FLAGS\*(C'\fR. Otherwise (the default), this environment variable will
override the flags completely if it is found in the environment. This is
@@ -462,14 +462,14 @@ This works by calling \f(CW\*(C`getpid ()\*(C'\fR on every iteration of the loop
and thus this might slow down your event loop if you do a lot of loop
iterations and little real work, but is usually not noticeable (on my
GNU/Linux system for example, \f(CW\*(C`getpid\*(C'\fR is actually a simple 5\-insn sequence
-without a syscall and thus \fIvery\fR fast, but my GNU/Linux system also has
+without a system call and thus \fIvery\fR fast, but my GNU/Linux system also has
\&\f(CW\*(C`pthread_atfork\*(C'\fR which is even faster).
.Sp
The big advantage of this flag is that you can forget about fork (and
forget about forgetting to tell libev about forking) when you use this
flag.
.Sp
-This flag setting cannot be overriden or specified in the \f(CW\*(C`LIBEV_FLAGS\*(C'\fR
+This flag setting cannot be overridden or specified in the \f(CW\*(C`LIBEV_FLAGS\*(C'\fR
environment variable.
.ie n .IP """EVBACKEND_SELECT"" (value 1, portable select backend)" 4
.el .IP "\f(CWEVBACKEND_SELECT\fR (value 1, portable select backend)" 4
@@ -481,7 +481,7 @@ using this backend. It doesn't scale too well (O(highest_fd)), but its
usually the fastest backend for a low number of (low-numbered :) fds.
.Sp
To get good performance out of this backend you need a high amount of
-parallelity (most of the file descriptors should be busy). If you are
+parallelism (most of the file descriptors should be busy). If you are
writing a server, you should \f(CW\*(C`accept ()\*(C'\fR in a loop to accept as many
connections as possible during one iteration. You might also want to have
a look at \f(CW\*(C`ev_set_io_collect_interval ()\*(C'\fR to increase the amount of
@@ -503,11 +503,11 @@ but it scales phenomenally better. While poll and select usually scale
like O(total_fds) where n is the total number of fds (or the highest fd),
epoll scales either O(1) or O(active_fds). The epoll design has a number
of shortcomings, such as silently dropping events in some hard-to-detect
-cases and requiring a syscall per fd change, no fork support and bad
+cases and requiring a system call per fd change, no fork support and bad
support for dup.
.Sp
While stopping, setting and starting an I/O watcher in the same iteration
-will result in some caching, there is still a syscall per such incident
+will result in some caching, there is still a system call per such incident
(because the fd could point to a different file description now), so its
best to avoid that. Also, \f(CW\*(C`dup ()\*(C'\fR'ed file descriptors might not work
very well if you register events for both fds.
@@ -520,7 +520,7 @@ Best performance from this backend is achieved by not unregistering all
watchers for a file descriptor until it has been closed, if possible, i.e.
keep at least one watcher active per fd at all times.
.Sp
-While nominally embeddeble in other event loops, this feature is broken in
+While nominally embeddable in other event loops, this feature is broken in
all kernel versions tested so far.
.ie n .IP """EVBACKEND_KQUEUE"" (value 8, most \s-1BSD\s0 clones)" 4
.el .IP "\f(CWEVBACKEND_KQUEUE\fR (value 8, most \s-1BSD\s0 clones)" 4
@@ -528,7 +528,7 @@ all kernel versions tested so far.
Kqueue deserves special mention, as at the time of this writing, it
was broken on all BSDs except NetBSD (usually it doesn't work reliably
with anything but sockets and pipes, except on Darwin, where of course
-it's completely useless). For this reason it's not being \*(L"autodetected\*(R"
+it's completely useless). For this reason it's not being \*(L"auto-detected\*(R"
unless you explicitly specify it explicitly in the flags (i.e. using
\&\f(CW\*(C`EVBACKEND_KQUEUE\*(C'\fR) or libev was compiled on a known-to-be-good (\-enough)
system like NetBSD.
@@ -540,7 +540,7 @@ the target platform). See \f(CW\*(C`ev_embed\*(C'\fR watchers for more info.
It scales in the same way as the epoll backend, but the interface to the
kernel is more efficient (which says nothing about its actual speed, of
course). While stopping, setting and starting an I/O watcher does never
-cause an extra syscall as with \f(CW\*(C`EVBACKEND_EPOLL\*(C'\fR, it still adds up to
+cause an extra system call as with \f(CW\*(C`EVBACKEND_EPOLL\*(C'\fR, it still adds up to
two event changes per incident, support for \f(CW\*(C`fork ()\*(C'\fR is very bad and it
drops fds silently in similarly hard-to-detect cases.
.Sp
@@ -565,7 +565,7 @@ immensely.
This uses the Solaris 10 event port mechanism. As with everything on Solaris,
it's really slow, but it still scales very well (O(active_fds)).
.Sp
-Please note that solaris event ports can deliver a lot of spurious
+Please note that Solaris event ports can deliver a lot of spurious
notifications, so you need to use non-blocking I/O or other means to avoid
blocking when no data (or space) is available.
.Sp
@@ -588,22 +588,22 @@ It is definitely not recommended to use this flag.
.RE
.RS 4
.Sp
-If one or more of these are ored into the flags value, then only these
+If one or more of these are or'ed into the flags value, then only these
backends will be tried (in the reverse order as listed here). If none are
specified, all backends in \f(CW\*(C`ev_recommended_backends ()\*(C'\fR will be tried.
.Sp
The most typical usage is like this:
.Sp
.Vb 2
-\& if (!ev_default_loop (0))
-\& fatal ("could not initialise libev, bad $LIBEV_FLAGS in environment?");
+\& if (!ev_default_loop (0))
+\& fatal ("could not initialise libev, bad $LIBEV_FLAGS in environment?");
.Ve
.Sp
Restrict libev to the select and poll backends, and do not allow
environment settings to be taken into account:
.Sp
.Vb 1
-\& ev_default_loop (EVBACKEND_POLL | EVBACKEND_SELECT | EVFLAG_NOENV);
+\& ev_default_loop (EVBACKEND_POLL | EVBACKEND_SELECT | EVFLAG_NOENV);
.Ve
.Sp
Use whatever libev has to offer, but make sure that kqueue is used if
@@ -611,7 +611,7 @@ available (warning, breaks stuff, best use only with your own private
event loop and only if you know the \s-1OS\s0 supports your types of fds):
.Sp
.Vb 1
-\& ev_default_loop (ev_recommended_backends () | EVBACKEND_KQUEUE);
+\& ev_default_loop (ev_recommended_backends () | EVBACKEND_KQUEUE);
.Ve
.RE
.IP "struct ev_loop *ev_loop_new (unsigned int flags)" 4
@@ -628,16 +628,16 @@ default loop in the \*(L"main\*(R" or \*(L"initial\*(R" thread.
Example: Try to create a event loop that uses epoll and nothing else.
.Sp
.Vb 3
-\& struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV);
-\& if (!epoller)
-\& fatal ("no epoll found here, maybe it hides under your chair");
+\& struct ev_loop *epoller = ev_loop_new (EVBACKEND_EPOLL | EVFLAG_NOENV);
+\& if (!epoller)
+\& fatal ("no epoll found here, maybe it hides under your chair");
.Ve
.IP "ev_default_destroy ()" 4
.IX Item "ev_default_destroy ()"
Destroys the default loop again (frees all memory and kernel state
etc.). None of the active event watchers will be stopped in the normal
sense, so e.g. \f(CW\*(C`ev_is_active\*(C'\fR might still return true. It is your
-responsibility to either stop all watchers cleanly yoursef \fIbefore\fR
+responsibility to either stop all watchers cleanly yourself \fIbefore\fR
calling this function, or cope with the fact afterwards (which is usually
the easiest thing, you can just ignore the watchers and/or \f(CW\*(C`free ()\*(C'\fR them
for example).
@@ -722,7 +722,7 @@ those events and any outstanding ones, but will not block your process in
case there are no events and will return after one iteration of the loop.
.Sp
A flags value of \f(CW\*(C`EVLOOP_ONESHOT\*(C'\fR will look for new events (waiting if
-neccessary) and will handle those and any outstanding ones. It will block
+necessary) and will handle those and any outstanding ones. It will block
your process until at least one new event arrives, and will return after
one iteration of the loop. This is useful if you are waiting for some
external event in conjunction with something not expressible using other
@@ -798,17 +798,17 @@ Example: Create a signal watcher, but keep it from keeping \f(CW\*(C`ev_loop\*(C
running when nothing else is active.
.Sp
.Vb 4
-\& struct ev_signal exitsig;
-\& ev_signal_init (&exitsig, sig_cb, SIGINT);
-\& ev_signal_start (loop, &exitsig);
-\& evf_unref (loop);
+\& struct ev_signal exitsig;
+\& ev_signal_init (&exitsig, sig_cb, SIGINT);
+\& ev_signal_start (loop, &exitsig);
+\& evf_unref (loop);
.Ve
.Sp
Example: For some weird reason, unregister the above signal handler again.
.Sp
.Vb 2
-\& ev_ref (loop);
-\& ev_signal_stop (loop, &exitsig);
+\& ev_ref (loop);
+\& ev_signal_stop (loop, &exitsig);
.Ve
.IP "ev_set_io_collect_interval (loop, ev_tstamp interval)" 4
.IX Item "ev_set_io_collect_interval (loop, ev_tstamp interval)"
@@ -842,11 +842,11 @@ latency (the watcher callback will be called later). \f(CW\*(C`ev_io\*(C'\fR wat
will not be affected. Setting this to a non-null value will not introduce
any overhead in libev.
.Sp
-Many (busy) programs can usually benefit by setting the io collect
+Many (busy) programs can usually benefit by setting the I/O collect
interval to a value near \f(CW0.1\fR or so, which is often enough for
interactive servers (of course not for games), likewise for timeouts. It
usually doesn't make much sense to set it to a lower value than \f(CW0.01\fR,
-as this approsaches the timing granularity of most systems.
+as this approaches the timing granularity of most systems.
.IP "ev_loop_verify (loop)" 4
.IX Item "ev_loop_verify (loop)"
This function only does something when \f(CW\*(C`EV_VERIFY\*(C'\fR support has been
@@ -864,18 +864,18 @@ interest in some event. For instance, if you want to wait for \s-1STDIN\s0 to
become readable, you would create an \f(CW\*(C`ev_io\*(C'\fR watcher for that:
.PP
.Vb 5
-\& static void my_cb (struct ev_loop *loop, struct ev_io *w, int revents)
-\& {
-\& ev_io_stop (w);
-\& ev_unloop (loop, EVUNLOOP_ALL);
-\& }
+\& static void my_cb (struct ev_loop *loop, struct ev_io *w, int revents)
+\& {
+\& ev_io_stop (w);
+\& ev_unloop (loop, EVUNLOOP_ALL);
+\& }
\&
-\& struct ev_loop *loop = ev_default_loop (0);
-\& struct ev_io stdin_watcher;
-\& ev_init (&stdin_watcher, my_cb);
-\& ev_io_set (&stdin_watcher, STDIN_FILENO, EV_READ);
-\& ev_io_start (loop, &stdin_watcher);
-\& ev_loop (loop, 0);
+\& struct ev_loop *loop = ev_default_loop (0);
+\& struct ev_io stdin_watcher;
+\& ev_init (&stdin_watcher, my_cb);
+\& ev_io_set (&stdin_watcher, STDIN_FILENO, EV_READ);
+\& ev_io_start (loop, &stdin_watcher);
+\& ev_loop (loop, 0);
.Ve
.PP
As you can see, you are responsible for allocating the memory for your
@@ -884,7 +884,7 @@ although this can sometimes be quite valid).
.PP
Each watcher structure must be initialised by a call to \f(CW\*(C`ev_init
(watcher *, callback)\*(C'\fR, which expects a callback to be provided. This
-callback gets invoked each time the event occurs (or, in the case of io
+callback gets invoked each time the event occurs (or, in the case of I/O
watchers, each time the event loop detects that the file descriptor given
is readable and/or writable).
.PP
@@ -974,7 +974,7 @@ The given async watcher has been asynchronously notified (see \f(CW\*(C`ev_async
.ie n .IP """EV_ERROR""" 4
.el .IP "\f(CWEV_ERROR\fR" 4
.IX Item "EV_ERROR"
-An unspecified error has occured, the watcher has been stopped. This might
+An unspecified error has occurred, the watcher has been stopped. This might
happen because the watcher could not be properly started because libev
ran out of memory, a file descriptor was found to be closed or any other
problem. You best act on it by reporting the problem and somehow coping
@@ -983,7 +983,7 @@ with the watcher being stopped.
Libev will usually signal a few \*(L"dummy\*(R" events together with an error,
for example it might indicate that a fd is readable or writable, and if
your callbacks is well-written it can just attempt the operation and cope
-with the error from \fIread()\fR or \fIwrite()\fR. This will not work in multithreaded
+with the error from \fIread()\fR or \fIwrite()\fR. This will not work in multi-threaded
programs, though, so beware.
.Sh "\s-1GENERIC\s0 \s-1WATCHER\s0 \s-1FUNCTIONS\s0"
.IX Subsection "GENERIC WATCHER FUNCTIONS"
@@ -1018,8 +1018,8 @@ Although some watcher types do not have type-specific arguments
.ie n .IP """ev_TYPE_init"" (ev_TYPE *watcher, callback, [args])" 4
.el .IP "\f(CWev_TYPE_init\fR (ev_TYPE *watcher, callback, [args])" 4
.IX Item "ev_TYPE_init (ev_TYPE *watcher, callback, [args])"
-This convinience macro rolls both \f(CW\*(C`ev_init\*(C'\fR and \f(CW\*(C`ev_TYPE_set\*(C'\fR macro
-calls into a single call. This is the most convinient method to initialise
+This convenience macro rolls both \f(CW\*(C`ev_init\*(C'\fR and \f(CW\*(C`ev_TYPE_set\*(C'\fR macro
+calls into a single call. This is the most convenient method to initialise
a watcher. The same limitations apply, of course.
.ie n .IP """ev_TYPE_start"" (loop *, ev_TYPE *watcher)" 4
.el .IP "\f(CWev_TYPE_start\fR (loop *, ev_TYPE *watcher)" 4
@@ -1104,24 +1104,24 @@ member, you can also \*(L"subclass\*(R" the watcher type and provide your own
data:
.PP
.Vb 7
-\& struct my_io
-\& {
-\& struct ev_io io;
-\& int otherfd;
-\& void *somedata;
-\& struct whatever *mostinteresting;
-\& }
+\& struct my_io
+\& {
+\& struct ev_io io;
+\& int otherfd;
+\& void *somedata;
+\& struct whatever *mostinteresting;
+\& }
.Ve
.PP
And since your callback will be called with a pointer to the watcher, you
can cast it back to your own type:
.PP
.Vb 5
-\& static void my_cb (struct ev_loop *loop, struct ev_io *w_, int revents)
-\& {
-\& struct my_io *w = (struct my_io *)w_;
-\& ...
-\& }
+\& static void my_cb (struct ev_loop *loop, struct ev_io *w_, int revents)
+\& {
+\& struct my_io *w = (struct my_io *)w_;
+\& ...
+\& }
.Ve
.PP
More interesting and less C\-conformant ways of casting your callback type
@@ -1131,33 +1131,33 @@ Another common scenario is having some data structure with multiple
watchers:
.PP
.Vb 6
-\& struct my_biggy
-\& {
-\& int some_data;
-\& ev_timer t1;
-\& ev_timer t2;
-\& }
+\& struct my_biggy
+\& {
+\& int some_data;
+\& ev_timer t1;
+\& ev_timer t2;
+\& }
.Ve
.PP
In this case getting the pointer to \f(CW\*(C`my_biggy\*(C'\fR is a bit more complicated,
you need to use \f(CW\*(C`offsetof\*(C'\fR:
.PP
.Vb 1
-\& #include <stddef.h>
-\&
-\& static void
-\& t1_cb (EV_P_ struct ev_timer *w, int revents)
-\& {
-\& struct my_biggy big = (struct my_biggy *
-\& (((char *)w) \- offsetof (struct my_biggy, t1));
-\& }
-\&
-\& static void
-\& t2_cb (EV_P_ struct ev_timer *w, int revents)
-\& {
-\& struct my_biggy big = (struct my_biggy *
-\& (((char *)w) \- offsetof (struct my_biggy, t2));
-\& }
+\& #include <stddef.h>
+\&
+\& static void
+\& t1_cb (EV_P_ struct ev_timer *w, int revents)
+\& {
+\& struct my_biggy big = (struct my_biggy *
+\& (((char *)w) \- offsetof (struct my_biggy, t1));
+\& }
+\&
+\& static void
+\& t2_cb (EV_P_ struct ev_timer *w, int revents)
+\& {
+\& struct my_biggy big = (struct my_biggy *
+\& (((char *)w) \- offsetof (struct my_biggy, t2));
+\& }
.Ve
.SH "WATCHER TYPES"
.IX Header "WATCHER TYPES"
@@ -1197,13 +1197,13 @@ Another thing you have to watch out for is that it is quite easy to
receive \*(L"spurious\*(R" readiness notifications, that is your callback might
be called with \f(CW\*(C`EV_READ\*(C'\fR but a subsequent \f(CW\*(C`read\*(C'\fR(2) will actually block
because there is no data. Not only are some backends known to create a
-lot of those (for example solaris ports), it is very easy to get into
+lot of those (for example Solaris ports), it is very easy to get into
this situation even with a relatively standard program structure. Thus
it is best to always use non-blocking I/O: An extra \f(CW\*(C`read\*(C'\fR(2) returning
\&\f(CW\*(C`EAGAIN\*(C'\fR is far preferable to a program hanging until some data arrives.
.PP
If you cannot run the fd in non-blocking mode (for example you should not
-play around with an Xlib connection), then you have to seperately re-test
+play around with an Xlib connection), then you have to separately re-test
whether a file descriptor is really ready with a known-to-be good interface
such as poll (fortunately in our Xlib example, Xlib already does this on
its own, so its quite safe to use).
@@ -1276,7 +1276,7 @@ somewhere, as that would have given you a big clue).
.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
-rceeive events for and events is either \f(CW\*(C`EV_READ\*(C'\fR, \f(CW\*(C`EV_WRITE\*(C'\fR or
+receive events for and events 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 receive the given events.
.IP "int fd [read\-only]" 4
.IX Item "int fd [read-only]"
@@ -1293,19 +1293,19 @@ readable, but only once. Since it is likely line-buffered, you could
attempt to read a whole line in the callback.
.PP
.Vb 6
-\& static void
-\& stdin_readable_cb (struct ev_loop *loop, struct ev_io *w, int revents)
-\& {
-\& ev_io_stop (loop, w);
-\& .. read from stdin here (or from w\->fd) and haqndle any I/O errors
-\& }
-\&
-\& ...
-\& struct ev_loop *loop = ev_default_init (0);
-\& struct ev_io stdin_readable;
-\& ev_io_init (&stdin_readable, stdin_readable_cb, STDIN_FILENO, EV_READ);
-\& ev_io_start (loop, &stdin_readable);
-\& ev_loop (loop, 0);
+\& static void
+\& stdin_readable_cb (struct ev_loop *loop, struct ev_io *w, int revents)
+\& {
+\& ev_io_stop (loop, w);
+\& .. read from stdin here (or from w\->fd) and haqndle any I/O errors
+\& }
+\&
+\& ...
+\& struct ev_loop *loop = ev_default_init (0);
+\& struct ev_io stdin_readable;
+\& ev_io_init (&stdin_readable, stdin_readable_cb, STDIN_FILENO, EV_READ);
+\& ev_io_start (loop, &stdin_readable);
+\& ev_loop (loop, 0);
.Ve
.ie n .Sh """ev_timer"" \- relative and optionally repeating timeouts"
.el .Sh "\f(CWev_timer\fP \- relative and optionally repeating timeouts"
@@ -1314,7 +1314,7 @@ Timer watchers are simple relative timers that generate an event after a
given time, and optionally repeating in regular intervals after that.
.PP
The timers are based on real time, that is, if you register an event that
-times out after an hour and you reset your system clock to january last
+times out after an hour and you reset your system clock to January last
year, it will still time out after (roughly) and hour. \*(L"Roughly\*(R" because
detecting time jumps is hard, and some inaccuracies are unavoidable (the
monotonic clock option helps a lot here).
@@ -1329,7 +1329,7 @@ on the current time, use something like this to adjust for this:
\& ev_timer_set (&timer, after + ev_now () \- ev_time (), 0.);
.Ve
.PP
-The callback is guarenteed to be invoked only after its timeout has passed,
+The callback is guaranteed to be invoked only after its timeout has passed,
but if multiple timers become ready during the same loop iteration then
order of execution is undefined.
.PP
@@ -1359,13 +1359,13 @@ repeating. The exact semantics are:
.Sp
If the timer is pending, its pending status is cleared.
.Sp
-If the timer is started but nonrepeating, stop it (as if it timed out).
+If the timer is started but non-repeating, 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
+example: Imagine you have a \s-1TCP\s0 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
@@ -1402,35 +1402,35 @@ which is also when any modifications are taken into account.
Example: Create a timer that fires after 60 seconds.
.PP
.Vb 5
-\& static void
-\& one_minute_cb (struct ev_loop *loop, struct ev_timer *w, int revents)
-\& {
-\& .. one minute over, w is actually stopped right here
-\& }
+\& static void
+\& one_minute_cb (struct ev_loop *loop, struct ev_timer *w, int revents)
+\& {
+\& .. one minute over, w is actually stopped right here
+\& }
\&
-\& struct ev_timer mytimer;
-\& ev_timer_init (&mytimer, one_minute_cb, 60., 0.);
-\& ev_timer_start (loop, &mytimer);
+\& struct ev_timer mytimer;
+\& ev_timer_init (&mytimer, one_minute_cb, 60., 0.);
+\& ev_timer_start (loop, &mytimer);
.Ve
.PP
Example: Create a timeout timer that times out after 10 seconds of
inactivity.
.PP
.Vb 5
-\& static void
-\& timeout_cb (struct ev_loop *loop, struct ev_timer *w, int revents)
-\& {
-\& .. ten seconds without any activity
-\& }
+\& static void
+\& timeout_cb (struct ev_loop *loop, struct ev_timer *w, int revents)
+\& {
+\& .. ten seconds without any activity
+\& }
\&
-\& struct ev_timer mytimer;
-\& ev_timer_init (&mytimer, timeout_cb, 0., 10.); /* note, only repeat used */
-\& ev_timer_again (&mytimer); /* start timer */
-\& ev_loop (loop, 0);
+\& struct ev_timer mytimer;
+\& ev_timer_init (&mytimer, timeout_cb, 0., 10.); /* note, only repeat used */
+\& ev_timer_again (&mytimer); /* start timer */
+\& ev_loop (loop, 0);
\&
-\& // and in some piece of code that gets executed on any "activity":
-\& // reset the timeout to start ticking again at 10 seconds
-\& ev_timer_again (&mytimer);
+\& // and in some piece of code that gets executed on any "activity":
+\& // reset the timeout to start ticking again at 10 seconds
+\& ev_timer_again (&mytimer);
.Ve
.ie n .Sh """ev_periodic"" \- to cron or not to cron?"
.el .Sh "\f(CWev_periodic\fP \- to cron or not to cron?"
@@ -1439,11 +1439,11 @@ Periodic watchers are also timers of a kind, but they are very versatile
(and unfortunately a bit complex).
.PP
Unlike \f(CW\*(C`ev_timer\*(C'\fR's, they are not based on real time (or relative time)
-but on wallclock time (absolute time). You can tell a periodic watcher
+but on wall clock time (absolute time). You can tell a periodic watcher
to trigger after 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 ()
+periodic watcher to trigger in 10 seconds (by specifying e.g. \f(CW\*(C`ev_now ()
+ 10.\*(C'\fR, that is, an absolute time not a delay) and then reset your system
-clock to january of the previous year, then it will take more than year
+clock to January of the previous year, then it will take more than year
to trigger the event (unlike an \f(CW\*(C`ev_timer\*(C'\fR, which would still trigger
roughly 10 seconds later as it uses a relative timeout).
.PP
@@ -1451,7 +1451,7 @@ roughly 10 seconds later as it uses a relative timeout).
such as triggering an event on each \*(L"midnight, local time\*(R", or other
complicated, rules.
.PP
-As with timers, the callback is guarenteed to be invoked only when the
+As with timers, the callback is guaranteed to be invoked only when the
time (\f(CW\*(C`at\*(C'\fR) has passed, but if multiple periodic timers become ready
during the same loop iteration then order of execution is undefined.
.PP
@@ -1469,7 +1469,7 @@ operation, and we will explain them from simplest to complex:
.IP "\(bu" 4
absolute timer (at = time, interval = reschedule_cb = 0)
.Sp
-In this configuration the watcher triggers an event after the wallclock
+In this configuration the watcher triggers an event after the wall clock
time \f(CW\*(C`at\*(C'\fR has passed 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.
@@ -1489,7 +1489,7 @@ the hour:
.Ve
.Sp
This doesn't mean there will always be 3600 seconds in between triggers,
-but only that the the callback will be called when the system time shows a
+but only that the callback will be called when the system time shows a
full hour (\s-1UTC\s0), or more correctly, when the system time is evenly divisible
by 3600.
.Sp
@@ -1501,9 +1501,9 @@ For numerical stability it is preferable that the \f(CW\*(C`at\*(C'\fR value is
\&\f(CW\*(C`ev_now ()\*(C'\fR (the current time), but there is no range requirement for
this value, and in fact is often specified as zero.
.Sp
-Note also that there is an upper limit to how often a timer can fire (cpu
+Note also that there is an upper limit to how often a timer can fire (\s-1CPU\s0
speed for example), so if \f(CW\*(C`interval\*(C'\fR is very small then timing stability
-will of course detoriate. Libev itself tries to be exact to be about one
+will of course deteriorate. Libev itself tries to be exact to be about one
millisecond (if the \s-1OS\s0 supports it and the machine is fast enough).
.IP "\(bu" 4
manual reschedule mode (at and interval ignored, reschedule_cb = callback)
@@ -1579,41 +1579,41 @@ the periodic timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called.
.PP
Example: Call a callback every hour, or, more precisely, whenever the
system clock is divisible by 3600. The callback invocation times have
-potentially a lot of jittering, but good long-term stability.
+potentially a lot of jitter, but good long-term stability.
.PP
.Vb 5
-\& static void
-\& clock_cb (struct ev_loop *loop, struct ev_io *w, int revents)
-\& {
-\& ... its now a full hour (UTC, or TAI or whatever your clock follows)
-\& }
+\& static void
+\& clock_cb (struct ev_loop *loop, struct ev_io *w, int revents)
+\& {
+\& ... its now a full hour (UTC, or TAI or whatever your clock follows)
+\& }
\&
-\& struct ev_periodic hourly_tick;
-\& ev_periodic_init (&hourly_tick, clock_cb, 0., 3600., 0);
-\& ev_periodic_start (loop, &hourly_tick);
+\& struct ev_periodic hourly_tick;
+\& ev_periodic_init (&hourly_tick, clock_cb, 0., 3600., 0);
+\& ev_periodic_start (loop, &hourly_tick);
.Ve
.PP
Example: The same as above, but use a reschedule callback to do it:
.PP
.Vb 1
-\& #include <math.h>
+\& #include <math.h>
\&
-\& static ev_tstamp
-\& my_scheduler_cb (struct ev_periodic *w, ev_tstamp now)
-\& {
-\& return fmod (now, 3600.) + 3600.;
-\& }
+\& static ev_tstamp
+\& my_scheduler_cb (struct ev_periodic *w, ev_tstamp now)
+\& {
+\& return fmod (now, 3600.) + 3600.;
+\& }
\&
-\& ev_periodic_init (&hourly_tick, clock_cb, 0., 0., my_scheduler_cb);
+\& ev_periodic_init (&hourly_tick, clock_cb, 0., 0., my_scheduler_cb);
.Ve
.PP
Example: Call a callback every hour, starting now:
.PP
.Vb 4
-\& struct ev_periodic hourly_tick;
-\& ev_periodic_init (&hourly_tick, clock_cb,
-\& fmod (ev_now (loop), 3600.), 3600., 0);
-\& ev_periodic_start (loop, &hourly_tick);
+\& struct ev_periodic hourly_tick;
+\& ev_periodic_init (&hourly_tick, clock_cb,
+\& fmod (ev_now (loop), 3600.), 3600., 0);
+\& ev_periodic_start (loop, &hourly_tick);
.Ve
.ie n .Sh """ev_signal"" \- signal me when a signal gets signalled!"
.el .Sh "\f(CWev_signal\fP \- signal me when a signal gets signalled!"
@@ -1631,8 +1631,8 @@ watcher for a signal is stopped libev will reset the signal handler to
\&\s-1SIG_DFL\s0 (regardless of what it was set to before).
.PP
If possible and supported, libev will install its handlers with
-\&\f(CW\*(C`SA_RESTART\*(C'\fR behaviour enabled, so syscalls should not be unduly
-interrupted. If you have a problem with syscalls getting interrupted by
+\&\f(CW\*(C`SA_RESTART\*(C'\fR behaviour enabled, so system calls should not be unduly
+interrupted. If you have a problem with system calls getting interrupted by
signals you can block all signals in an \f(CW\*(C`ev_check\*(C'\fR watcher and unblock
them in an \f(CW\*(C`ev_prepare\*(C'\fR watcher.
.PP
@@ -1656,15 +1656,15 @@ The signal the watcher watches out for.
Example: Try to exit cleanly on \s-1SIGINT\s0 and \s-1SIGTERM\s0.
.PP
.Vb 5
-\& static void
-\& sigint_cb (struct ev_loop *loop, struct ev_signal *w, int revents)
-\& {
-\& ev_unloop (loop, EVUNLOOP_ALL);
-\& }
+\& static void
+\& sigint_cb (struct ev_loop *loop, struct ev_signal *w, int revents)
+\& {
+\& ev_unloop (loop, EVUNLOOP_ALL);
+\& }
\&
-\& struct ev_signal signal_watcher;
-\& ev_signal_init (&signal_watcher, sigint_cb, SIGINT);
-\& ev_signal_start (loop, &sigint_cb);
+\& struct ev_signal signal_watcher;
+\& ev_signal_init (&signal_watcher, sigint_cb, SIGINT);
+\& ev_signal_start (loop, &sigint_cb);
.Ve
.ie n .Sh """ev_child"" \- watch out for process status changes"
.el .Sh "\f(CWev_child\fP \- watch out for process status changes"
@@ -1676,14 +1676,14 @@ forked (which implies it might have already exited), as long as the event
loop isn't entered (or is continued from a watcher).
.PP
Only the default event loop is capable of handling signals, and therefore
-you can only rgeister child watchers in the default event loop.
+you can only register child watchers in the default event loop.
.PP
\fIProcess Interaction\fR
.IX Subsection "Process Interaction"
.PP
Libev grabs \f(CW\*(C`SIGCHLD\*(C'\fR as soon as the default event loop is
initialised. This is necessary to guarantee proper behaviour even if
-the first child watcher is started after the child exits. The occurance
+the first child watcher is started after the child exits. The occurrence
of \f(CW\*(C`SIGCHLD\*(C'\fR is recorded asynchronously, but child reaping is done
synchronously as part of the event loop processing. Libev always reaps all
children, even ones not watched.
@@ -1733,34 +1733,34 @@ Example: \f(CW\*(C`fork()\*(C'\fR a new process and install a child handler to w
its completion.
.PP
.Vb 1
-\& ev_child cw;
-\&
-\& static void
-\& child_cb (EV_P_ struct ev_child *w, int revents)
-\& {
-\& ev_child_stop (EV_A_ w);
-\& printf ("process %d exited with status %x\en", w\->rpid, w\->rstatus);
-\& }
-\&
-\& pid_t pid = fork ();
-\&
-\& if (pid < 0)
-\& // error
-\& else if (pid == 0)
-\& {
-\& // the forked child executes here
-\& exit (1);
-\& }
-\& else
-\& {
-\& ev_child_init (&cw, child_cb, pid, 0);
-\& ev_child_start (EV_DEFAULT_ &cw);
-\& }
+\& ev_child cw;
+\&
+\& static void
+\& child_cb (EV_P_ struct ev_child *w, int revents)
+\& {
+\& ev_child_stop (EV_A_ w);
+\& printf ("process %d exited with status %x\en", w\->rpid, w\->rstatus);
+\& }
+\&
+\& pid_t pid = fork ();
+\&
+\& if (pid < 0)
+\& // error
+\& else if (pid == 0)
+\& {
+\& // the forked child executes here
+\& exit (1);
+\& }
+\& else
+\& {
+\& ev_child_init (&cw, child_cb, pid, 0);
+\& ev_child_start (EV_DEFAULT_ &cw);
+\& }
.Ve
.ie n .Sh """ev_stat"" \- did the file attributes just change?"
.el .Sh "\f(CWev_stat\fP \- did the file attributes just change?"
.IX Subsection "ev_stat - did the file attributes just change?"
-This watches a filesystem path for attribute changes. That is, it calls
+This watches a file system path for attribute changes. That is, it calls
\&\f(CW\*(C`stat\*(C'\fR regularly (or when the \s-1OS\s0 says it changed) and sees if it changed
compared to the last time, invoking the callback if it did.
.PP
@@ -1805,7 +1805,7 @@ structure. When using the library from programs that change the \s-1ABI\s0 to
use 64 bit file offsets the programs will fail. In that case you have to
compile libev with the same flags to get binary compatibility. This is
obviously the case with any flags that change the \s-1ABI\s0, but the problem is
-most noticably with ev_stat and largefile support.
+most noticeably with ev_stat and large file support.
.PP
\fIInotify\fR
.IX Subsection "Inotify"
@@ -1827,8 +1827,8 @@ descriptor open on the object at all times).
\fIThe special problem of stat time resolution\fR
.IX Subsection "The special problem of stat time resolution"
.PP
-The \f(CW\*(C`stat ()\*(C'\fR syscall only supports full-second resolution portably, and
-even on systems where the resolution is higher, many filesystems still
+The \f(CW\*(C`stat ()\*(C'\fR system call only supports full-second resolution portably, and
+even on systems where the resolution is higher, many file systems still
only support whole seconds.
.PP
That means that, if the time is the only thing that changes, you can
@@ -1893,7 +1893,7 @@ differ: \f(CW\*(C`st_dev\*(C'\fR, \f(CW\*(C`st_ino\*(C'\fR, \f(CW\*(C`st_mode\*(
The specified interval.
.IP "const char *path [read\-only]" 4
.IX Item "const char *path [read-only]"
-The filesystem path that is being watched.
+The file system path that is being watched.
.PP
\fIExamples\fR
.IX Subsection "Examples"
@@ -1901,27 +1901,27 @@ The filesystem path that is being watched.
Example: Watch \f(CW\*(C`/etc/passwd\*(C'\fR for attribute changes.
.PP
.Vb 10
-\& static void
-\& passwd_cb (struct ev_loop *loop, ev_stat *w, int revents)
-\& {
-\& /* /etc/passwd changed in some way */
-\& if (w\->attr.st_nlink)
-\& {
-\& printf ("passwd current size %ld\en", (long)w\->attr.st_size);
-\& printf ("passwd current atime %ld\en", (long)w\->attr.st_mtime);
-\& printf ("passwd current mtime %ld\en", (long)w\->attr.st_mtime);
-\& }
-\& else
-\& /* you shalt not abuse printf for puts */
-\& puts ("wow, /etc/passwd is not there, expect problems. "
-\& "if this is windows, they already arrived\en");
-\& }
-\&
-\& ...
-\& ev_stat passwd;
-\&
-\& ev_stat_init (&passwd, passwd_cb, "/etc/passwd", 0.);
-\& ev_stat_start (loop, &passwd);
+\& static void
+\& passwd_cb (struct ev_loop *loop, ev_stat *w, int revents)
+\& {
+\& /* /etc/passwd changed in some way */
+\& if (w\->attr.st_nlink)
+\& {
+\& printf ("passwd current size %ld\en", (long)w\->attr.st_size);
+\& printf ("passwd current atime %ld\en", (long)w\->attr.st_mtime);
+\& printf ("passwd current mtime %ld\en", (long)w\->attr.st_mtime);
+\& }
+\& else
+\& /* you shalt not abuse printf for puts */
+\& puts ("wow, /etc/passwd is not there, expect problems. "
+\& "if this is windows, they already arrived\en");
+\& }
+\&
+\& ...
+\& ev_stat passwd;
+\&
+\& ev_stat_init (&passwd, passwd_cb, "/etc/passwd", 0.);
+\& ev_stat_start (loop, &passwd);
.Ve
.PP
Example: Like above, but additionally use a one-second delay so we do not
@@ -1930,28 +1930,28 @@ one might do the work both on \f(CW\*(C`ev_stat\*(C'\fR callback invocation \fIa
\&\f(CW\*(C`ev_timer\*(C'\fR callback invocation).
.PP
.Vb 2
-\& static ev_stat passwd;
-\& static ev_timer timer;
+\& static ev_stat passwd;
+\& static ev_timer timer;
\&
-\& static void
-\& timer_cb (EV_P_ ev_timer *w, int revents)
-\& {
-\& ev_timer_stop (EV_A_ w);
+\& static void
+\& timer_cb (EV_P_ ev_timer *w, int revents)
+\& {
+\& ev_timer_stop (EV_A_ w);
\&
-\& /* now it\*(Aqs one second after the most recent passwd change */
-\& }
+\& /* now it\*(Aqs one second after the most recent passwd change */
+\& }
\&
-\& static void
-\& stat_cb (EV_P_ ev_stat *w, int revents)
-\& {
-\& /* reset the one\-second timer */
-\& ev_timer_again (EV_A_ &timer);
-\& }
+\& static void
+\& stat_cb (EV_P_ ev_stat *w, int revents)
+\& {
+\& /* reset the one\-second timer */
+\& ev_timer_again (EV_A_ &timer);
+\& }
\&
-\& ...
-\& ev_stat_init (&passwd, stat_cb, "/etc/passwd", 0.);
-\& ev_stat_start (loop, &passwd);
-\& ev_timer_init (&timer, timer_cb, 0., 1.02);
+\& ...
+\& ev_stat_init (&passwd, stat_cb, "/etc/passwd", 0.);
+\& ev_stat_start (loop, &passwd);
+\& ev_timer_init (&timer, timer_cb, 0., 1.02);
.Ve
.ie n .Sh """ev_idle"" \- when you've got nothing better to do..."
.el .Sh "\f(CWev_idle\fP \- when you've got nothing better to do..."
@@ -1990,17 +1990,17 @@ Example: Dynamically allocate an \f(CW\*(C`ev_idle\*(C'\fR watcher, start it, an
callback, free it. Also, use no error checking, as usual.
.PP
.Vb 7
-\& static void
-\& idle_cb (struct ev_loop *loop, struct ev_idle *w, int revents)
-\& {
-\& free (w);
-\& // now do something you wanted to do when the program has
-\& // no longer anything immediate to do.
-\& }
-\&
-\& struct ev_idle *idle_watcher = malloc (sizeof (struct ev_idle));
-\& ev_idle_init (idle_watcher, idle_cb);
-\& ev_idle_start (loop, idle_cb);
+\& static void
+\& idle_cb (struct ev_loop *loop, struct ev_idle *w, int revents)
+\& {
+\& free (w);
+\& // now do something you wanted to do when the program has
+\& // no longer anything immediate to do.
+\& }
+\&
+\& struct ev_idle *idle_watcher = malloc (sizeof (struct ev_idle));
+\& ev_idle_init (idle_watcher, idle_cb);
+\& ev_idle_start (loop, idle_cb);
.Ve
.ie n .Sh """ev_prepare""\fP and \f(CW""ev_check"" \- customise your event loop!"
.el .Sh "\f(CWev_prepare\fP and \f(CWev_check\fP \- customise your event loop!"
@@ -2029,7 +2029,7 @@ This is done by examining in each prepare call which file descriptors need
to be watched by the other library, registering \f(CW\*(C`ev_io\*(C'\fR watchers for
them and starting an \f(CW\*(C`ev_timer\*(C'\fR watcher for any timeouts (many libraries
provide just this functionality). Then, in the check watcher you check for
-any events that occured (by checking the pending status of all watchers
+any events that occurred (by checking the pending status of all watchers
and stopping them) and call back into the library. The I/O and timer
callbacks will never actually be called (but must be valid nevertheless,
because you never know, you know?).
@@ -2082,123 +2082,123 @@ priority for the check watcher or use \f(CW\*(C`ev_clear_pending\*(C'\fR explici
the callbacks for the IO/timeout watchers might not have been called yet.
.PP
.Vb 2
-\& static ev_io iow [nfd];
-\& static ev_timer tw;
-\&
-\& static void
-\& io_cb (ev_loop *loop, ev_io *w, int revents)
-\& {
-\& }
-\&
-\& // create io watchers for each fd and a timer before blocking
-\& static void
-\& adns_prepare_cb (ev_loop *loop, ev_prepare *w, int revents)
-\& {
-\& int timeout = 3600000;
-\& struct pollfd fds [nfd];
-\& // actual code will need to loop here and realloc etc.
-\& adns_beforepoll (ads, fds, &nfd, &timeout, timeval_from (ev_time ()));
-\&
-\& /* the callback is illegal, but won\*(Aqt be called as we stop during check */
-\& ev_timer_init (&tw, 0, timeout * 1e\-3);
-\& ev_timer_start (loop, &tw);
-\&
-\& // create one ev_io per pollfd
-\& for (int i = 0; i < nfd; ++i)
-\& {
-\& ev_io_init (iow + i, io_cb, fds [i].fd,
-\& ((fds [i].events & POLLIN ? EV_READ : 0)
-\& | (fds [i].events & POLLOUT ? EV_WRITE : 0)));
-\&
-\& fds [i].revents = 0;
-\& ev_io_start (loop, iow + i);
-\& }
-\& }
-\&
-\& // stop all watchers after blocking
-\& static void
-\& adns_check_cb (ev_loop *loop, ev_check *w, int revents)
-\& {
-\& ev_timer_stop (loop, &tw);
-\&
-\& for (int i = 0; i < nfd; ++i)
-\& {
-\& // set the relevant poll flags
-\& // could also call adns_processreadable etc. here
-\& struct pollfd *fd = fds + i;
-\& int revents = ev_clear_pending (iow + i);
-\& if (revents & EV_READ ) fd\->revents |= fd\->events & POLLIN;
-\& if (revents & EV_WRITE) fd\->revents |= fd\->events & POLLOUT;
-\&
-\& // now stop the watcher
-\& ev_io_stop (loop, iow + i);
-\& }
-\&
-\& adns_afterpoll (adns, fds, nfd, timeval_from (ev_now (loop));
-\& }
+\& static ev_io iow [nfd];
+\& static ev_timer tw;
+\&
+\& static void
+\& io_cb (ev_loop *loop, ev_io *w, int revents)
+\& {
+\& }
+\&
+\& // create io watchers for each fd and a timer before blocking
+\& static void
+\& adns_prepare_cb (ev_loop *loop, ev_prepare *w, int revents)
+\& {
+\& int timeout = 3600000;
+\& struct pollfd fds [nfd];
+\& // actual code will need to loop here and realloc etc.
+\& adns_beforepoll (ads, fds, &nfd, &timeout, timeval_from (ev_time ()));
+\&
+\& /* the callback is illegal, but won\*(Aqt be called as we stop during check */
+\& ev_timer_init (&tw, 0, timeout * 1e\-3);
+\& ev_timer_start (loop, &tw);
+\&
+\& // create one ev_io per pollfd
+\& for (int i = 0; i < nfd; ++i)
+\& {
+\& ev_io_init (iow + i, io_cb, fds [i].fd,
+\& ((fds [i].events & POLLIN ? EV_READ : 0)
+\& | (fds [i].events & POLLOUT ? EV_WRITE : 0)));
+\&
+\& fds [i].revents = 0;
+\& ev_io_start (loop, iow + i);
+\& }
+\& }
+\&
+\& // stop all watchers after blocking
+\& static void
+\& adns_check_cb (ev_loop *loop, ev_check *w, int revents)
+\& {
+\& ev_timer_stop (loop, &tw);
+\&
+\& for (int i = 0; i < nfd; ++i)
+\& {
+\& // set the relevant poll flags
+\& // could also call adns_processreadable etc. here
+\& struct pollfd *fd = fds + i;
+\& int revents = ev_clear_pending (iow + i);
+\& if (revents & EV_READ ) fd\->revents |= fd\->events & POLLIN;
+\& if (revents & EV_WRITE) fd\->revents |= fd\->events & POLLOUT;
+\&
+\& // now stop the watcher
+\& ev_io_stop (loop, iow + i);
+\& }
+\&
+\& adns_afterpoll (adns, fds, nfd, timeval_from (ev_now (loop));
+\& }
.Ve
.PP
Method 2: This would be just like method 1, but you run \f(CW\*(C`adns_afterpoll\*(C'\fR
in the prepare watcher and would dispose of the check watcher.
.PP
Method 3: If the module to be embedded supports explicit event
-notification (adns does), you can also make use of the actual watcher
+notification (libadns does), you can also make use of the actual watcher
callbacks, and only destroy/create the watchers in the prepare watcher.
.PP
.Vb 5
-\& static void
-\& timer_cb (EV_P_ ev_timer *w, int revents)
-\& {
-\& adns_state ads = (adns_state)w\->data;
-\& update_now (EV_A);
+\& static void
+\& timer_cb (EV_P_ ev_timer *w, int revents)
+\& {
+\& adns_state ads = (adns_state)w\->data;
+\& update_now (EV_A);
\&
-\& adns_processtimeouts (ads, &tv_now);
-\& }
+\& adns_processtimeouts (ads, &tv_now);
+\& }
\&
-\& static void
-\& io_cb (EV_P_ ev_io *w, int revents)
-\& {
-\& adns_state ads = (adns_state)w\->data;
-\& update_now (EV_A);
+\& static void
+\& io_cb (EV_P_ ev_io *w, int revents)
+\& {
+\& adns_state ads = (adns_state)w\->data;
+\& update_now (EV_A);
\&
-\& if (revents & EV_READ ) adns_processreadable (ads, w\->fd, &tv_now);
-\& if (revents & EV_WRITE) adns_processwriteable (ads, w\->fd, &tv_now);
-\& }
+\& if (revents & EV_READ ) adns_processreadable (ads, w\->fd, &tv_now);
+\& if (revents & EV_WRITE) adns_processwriteable (ads, w\->fd, &tv_now);
+\& }
\&
-\& // do not ever call adns_afterpoll
+\& // do not ever call adns_afterpoll
.Ve
.PP
Method 4: Do not use a prepare or check watcher because the module you
-want to embed is too inflexible to support it. Instead, youc na override
+want to embed is too inflexible to support it. Instead, you can override
their poll function. The drawback with this solution is that the main
loop is now no longer controllable by \s-1EV\s0. The \f(CW\*(C`Glib::EV\*(C'\fR module does
this.
.PP
.Vb 4
-\& static gint
-\& event_poll_func (GPollFD *fds, guint nfds, gint timeout)
-\& {
-\& int got_events = 0;
+\& static gint
+\& event_poll_func (GPollFD *fds, guint nfds, gint timeout)
+\& {
+\& int got_events = 0;
\&
-\& for (n = 0; n < nfds; ++n)
-\& // create/start io watcher that sets the relevant bits in fds[n] and increment got_events
+\& for (n = 0; n < nfds; ++n)
+\& // create/start io watcher that sets the relevant bits in fds[n] and increment got_events
\&
-\& if (timeout >= 0)
-\& // create/start timer
+\& if (timeout >= 0)
+\& // create/start timer
\&
-\& // poll
-\& ev_loop (EV_A_ 0);
+\& // poll
+\& ev_loop (EV_A_ 0);
\&
-\& // stop timer again
-\& if (timeout >= 0)
-\& ev_timer_stop (EV_A_ &to);
+\& // stop timer again
+\& if (timeout >= 0)
+\& ev_timer_stop (EV_A_ &to);
\&
-\& // stop io watchers again \- their callbacks should have set
-\& for (n = 0; n < nfds; ++n)
-\& ev_io_stop (EV_A_ iow [n]);
+\& // stop io watchers again \- their callbacks should have set
+\& for (n = 0; n < nfds; ++n)
+\& ev_io_stop (EV_A_ iow [n]);
\&
-\& return got_events;
-\& }
+\& return got_events;
+\& }
.Ve
.ie n .Sh """ev_embed"" \- when one backend isn't enough..."
.el .Sh "\f(CWev_embed\fP \- when one backend isn't enough..."
@@ -2264,12 +2264,12 @@ Configures the watcher to embed the given loop, which must be
embeddable. If the callback is \f(CW0\fR, then \f(CW\*(C`ev_embed_sweep\*(C'\fR will be
invoked automatically, otherwise it is the responsibility of the callback
to invoke it (it will continue to be called until the sweep has been done,
-if you do not want thta, you need to temporarily stop the embed watcher).
+if you do not want that, you need to temporarily stop the embed watcher).
.IP "ev_embed_sweep (loop, ev_embed *)" 4
.IX Item "ev_embed_sweep (loop, ev_embed *)"
Make a single, non-blocking sweep over the embedded loop. This works
similarly to \f(CW\*(C`ev_loop (embedded_loop, EVLOOP_NONBLOCK)\*(C'\fR, but in the most
-apropriate way for embedded loops.
+appropriate way for embedded loops.
.IP "struct ev_loop *other [read\-only]" 4
.IX Item "struct ev_loop *other [read-only]"
The embedded event loop.
@@ -2279,29 +2279,29 @@ The embedded event loop.
.PP
Example: Try to get an embeddable event loop and embed it into the default
event loop. If that is not possible, use the default loop. The default
-loop is stored in \f(CW\*(C`loop_hi\*(C'\fR, while the mebeddable loop is stored in
-\&\f(CW\*(C`loop_lo\*(C'\fR (which is \f(CW\*(C`loop_hi\*(C'\fR in the acse no embeddable loop can be
+loop is stored in \f(CW\*(C`loop_hi\*(C'\fR, while the embeddable loop is stored in
+\&\f(CW\*(C`loop_lo\*(C'\fR (which is \f(CW\*(C`loop_hi\*(C'\fR in the case no embeddable loop can be
used).
.PP
.Vb 3
-\& struct ev_loop *loop_hi = ev_default_init (0);
-\& struct ev_loop *loop_lo = 0;
-\& struct ev_embed embed;
-\&
-\& // see if there is a chance of getting one that works
-\& // (remember that a flags value of 0 means autodetection)
-\& loop_lo = ev_embeddable_backends () & ev_recommended_backends ()
-\& ? ev_loop_new (ev_embeddable_backends () & ev_recommended_backends ())
-\& : 0;
-\&
-\& // if we got one, then embed it, otherwise default to loop_hi
-\& if (loop_lo)
-\& {
-\& ev_embed_init (&embed, 0, loop_lo);
-\& ev_embed_start (loop_hi, &embed);
-\& }
-\& else
-\& loop_lo = loop_hi;
+\& struct ev_loop *loop_hi = ev_default_init (0);
+\& struct ev_loop *loop_lo = 0;
+\& struct ev_embed embed;
+\&
+\& // see if there is a chance of getting one that works
+\& // (remember that a flags value of 0 means autodetection)
+\& loop_lo = ev_embeddable_backends () & ev_recommended_backends ()
+\& ? ev_loop_new (ev_embeddable_backends () & ev_recommended_backends ())
+\& : 0;
+\&
+\& // if we got one, then embed it, otherwise default to loop_hi
+\& if (loop_lo)
+\& {
+\& ev_embed_init (&embed, 0, loop_lo);
+\& ev_embed_start (loop_hi, &embed);
+\& }
+\& else
+\& loop_lo = loop_hi;
.Ve
.PP
Example: Check if kqueue is available but not recommended and create
@@ -2310,21 +2310,21 @@ kqueue implementation). Store the kqueue/socket\-only event loop in
\&\f(CW\*(C`loop_socket\*(C'\fR. (One might optionally use \f(CW\*(C`EVFLAG_NOENV\*(C'\fR, too).
.PP
.Vb 3
-\& struct ev_loop *loop = ev_default_init (0);
-\& struct ev_loop *loop_socket = 0;
-\& struct ev_embed embed;
-\&
-\& if (ev_supported_backends () & ~ev_recommended_backends () & EVBACKEND_KQUEUE)
-\& if ((loop_socket = ev_loop_new (EVBACKEND_KQUEUE))
-\& {
-\& ev_embed_init (&embed, 0, loop_socket);
-\& ev_embed_start (loop, &embed);
-\& }
-\&
-\& if (!loop_socket)
-\& loop_socket = loop;
-\&
-\& // now use loop_socket for all sockets, and loop for everything else
+\& struct ev_loop *loop = ev_default_init (0);
+\& struct ev_loop *loop_socket = 0;
+\& struct ev_embed embed;
+\&
+\& if (ev_supported_backends () & ~ev_recommended_backends () & EVBACKEND_KQUEUE)
+\& if ((loop_socket = ev_loop_new (EVBACKEND_KQUEUE))
+\& {
+\& ev_embed_init (&embed, 0, loop_socket);
+\& ev_embed_start (loop, &embed);
+\& }
+\&
+\& if (!loop_socket)
+\& loop_socket = loop;
+\&
+\& // now use loop_socket for all sockets, and loop for everything else
.Ve
.ie n .Sh """ev_fork"" \- the audacity to resume the event loop after a fork"
.el .Sh "\f(CWev_fork\fP \- the audacity to resume the event loop after a fork"
@@ -2380,7 +2380,7 @@ queue:
.IX Item "queueing from a signal handler context"
To implement race-free queueing, you simply add to the queue in the signal
handler but you block the signal handler in the watcher callback. Here is an example that does that for
-some fictitiuous \s-1SIGUSR1\s0 handler:
+some fictitious \s-1SIGUSR1\s0 handler:
.Sp
.Vb 1
\& static ev_async mysig;
@@ -2461,11 +2461,11 @@ believe me.
Sends/signals/activates the given \f(CW\*(C`ev_async\*(C'\fR watcher, that is, feeds
an \f(CW\*(C`EV_ASYNC\*(C'\fR event on the watcher into the event loop. Unlike
\&\f(CW\*(C`ev_feed_event\*(C'\fR, this call is safe to do in other threads, signal or
-similar contexts (see the dicusssion of \f(CW\*(C`EV_ATOMIC_T\*(C'\fR in the embedding
+similar contexts (see the discussion of \f(CW\*(C`EV_ATOMIC_T\*(C'\fR in the embedding
section below on what exactly this means).
.Sp
-This call incurs the overhead of a syscall only once per loop iteration,
-so while the overhead might be noticable, it doesn't apply to repeated
+This call incurs the overhead of a system call only once per loop iteration,
+so while the overhead might be noticeable, it doesn't apply to repeated
calls to \f(CW\*(C`ev_async_send\*(C'\fR.
.IP "bool = ev_async_pending (ev_async *)" 4
.IX Item "bool = ev_async_pending (ev_async *)"
@@ -2476,10 +2476,10 @@ event loop.
\&\f(CW\*(C`ev_async_send\*(C'\fR sets a flag in the watcher and wakes up the loop. When
the loop iterates next and checks for the watcher to have become active,
it will reset the flag again. \f(CW\*(C`ev_async_pending\*(C'\fR can be used to very
-quickly check wether invoking the loop might be a good idea.
+quickly check whether invoking the loop might be a good idea.
.Sp
-Not that this does \fInot\fR check wether the watcher itself is pending, only
-wether it has been requested to make this watcher pending.
+Not that this does \fInot\fR check whether the watcher itself is pending, only
+whether it has been requested to make this watcher pending.
.SH "OTHER FUNCTIONS"
.IX Header "OTHER FUNCTIONS"
There are some other functions of possible interest. Described. Here. Now.
@@ -2493,7 +2493,7 @@ more watchers yourself.
.Sp
If \f(CW\*(C`fd\*(C'\fR is less than 0, then no I/O watcher will be started and events
is being ignored. Otherwise, an \f(CW\*(C`ev_io\*(C'\fR watcher for the given \f(CW\*(C`fd\*(C'\fR and
-\&\f(CW\*(C`events\*(C'\fR set will be craeted and started.
+\&\f(CW\*(C`events\*(C'\fR set will be created and started.
.Sp
If \f(CW\*(C`timeout\*(C'\fR is less than 0, then no timeout watcher will be
started. Otherwise an \f(CW\*(C`ev_timer\*(C'\fR watcher with after = \f(CW\*(C`timeout\*(C'\fR (and
@@ -2506,15 +2506,15 @@ passed an \f(CW\*(C`revents\*(C'\fR set like normal event callbacks (a combinati
value passed to \f(CW\*(C`ev_once\*(C'\fR:
.Sp
.Vb 7
-\& static void stdin_ready (int revents, void *arg)
-\& {
-\& if (revents & EV_TIMEOUT)
-\& /* doh, nothing entered */;
-\& else if (revents & EV_READ)
-\& /* stdin might have data for us, joy! */;
-\& }
+\& static void stdin_ready (int revents, void *arg)
+\& {
+\& if (revents & EV_TIMEOUT)
+\& /* doh, nothing entered */;
+\& else if (revents & EV_READ)
+\& /* stdin might have data for us, joy! */;
+\& }
\&
-\& ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0);
+\& ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0);
.Ve
.IP "ev_feed_event (ev_loop *, watcher *, int revents)" 4
.IX Item "ev_feed_event (ev_loop *, watcher *, int revents)"
@@ -2527,7 +2527,7 @@ Feed an event on the given fd, as if a file descriptor backend detected
the given events it.
.IP "ev_feed_signal_event (ev_loop *loop, int signum)" 4
.IX Item "ev_feed_signal_event (ev_loop *loop, int signum)"
-Feed an event as if the given signal occured (\f(CW\*(C`loop\*(C'\fR must be the default
+Feed an event as if the given signal occurred (\f(CW\*(C`loop\*(C'\fR must be the default
loop!).
.SH "LIBEVENT EMULATION"
.IX Header "LIBEVENT EMULATION"
@@ -2557,13 +2557,13 @@ to use the libev header file and library.
.SH "\*(C+ SUPPORT"
.IX Header " SUPPORT"
Libev comes with some simplistic wrapper classes for \*(C+ that mainly allow
-you to use some convinience methods to start/stop watchers and also change
+you to use some convenience methods to start/stop watchers and also change
the callback model to a model using method callbacks on objects.
.PP
To use it,
.PP
.Vb 1
-\& #include <ev++.h>
+\& #include <ev++.h>
.Ve
.PP
This automatically includes \fIev.h\fR and puts all of its definitions (many
@@ -2639,14 +2639,14 @@ thunking function, making it as fast as a direct C callback.
Example: simple class declaration and watcher initialisation
.Sp
.Vb 4
-\& struct myclass
-\& {
-\& void io_cb (ev::io &w, int revents) { }
-\& }
+\& struct myclass
+\& {
+\& void io_cb (ev::io &w, int revents) { }
+\& }
\&
-\& myclass obj;
-\& ev::io iow;
-\& iow.set <myclass, &myclass::io_cb> (&obj);
+\& myclass obj;
+\& ev::io iow;
+\& iow.set <myclass, &myclass::io_cb> (&obj);
.Ve
.IP "w\->set<function> (void *data = 0)" 4
.IX Item "w->set<function> (void *data = 0)"
@@ -2661,16 +2661,16 @@ See the method\-\f(CW\*(C`set\*(C'\fR above for more details.
Example:
.Sp
.Vb 2
-\& static void io_cb (ev::io &w, int revents) { }
-\& iow.set <io_cb> ();
+\& static void io_cb (ev::io &w, int revents) { }
+\& iow.set <io_cb> ();
.Ve
.IP "w\->set (struct ev_loop *)" 4
.IX Item "w->set (struct ev_loop *)"
Associates a different \f(CW\*(C`struct ev_loop\*(C'\fR with this watcher. You can only
do this when the watcher is inactive (and not pending either).
-.IP "w\->set ([args])" 4
-.IX Item "w->set ([args])"
-Basically the same as \f(CW\*(C`ev_TYPE_set\*(C'\fR, with the same args. Must be
+.IP "w\->set ([arguments])" 4
+.IX Item "w->set ([arguments])"
+Basically the same as \f(CW\*(C`ev_TYPE_set\*(C'\fR, with the same arguments. Must be
called at least once. Unlike the C counterpart, an active watcher gets
automatically stopped and restarted when reconfiguring it with this
method.
@@ -2702,24 +2702,24 @@ Example: Define a class with an \s-1IO\s0 and idle watcher, start one of them in
the constructor.
.PP
.Vb 4
-\& class myclass
-\& {
-\& ev::io io; void io_cb (ev::io &w, int revents);
-\& ev:idle idle void idle_cb (ev::idle &w, int revents);
+\& class myclass
+\& {
+\& ev::io io; void io_cb (ev::io &w, int revents);
+\& ev:idle idle void idle_cb (ev::idle &w, int revents);
\&
-\& myclass (int fd)
-\& {
-\& io .set <myclass, &myclass::io_cb > (this);
-\& idle.set <myclass, &myclass::idle_cb> (this);
+\& myclass (int fd)
+\& {
+\& io .set <myclass, &myclass::io_cb > (this);
+\& idle.set <myclass, &myclass::idle_cb> (this);
\&
-\& io.start (fd, ev::READ);
-\& }
-\& };
+\& io.start (fd, ev::READ);
+\& }
+\& };
.Ve
.SH "OTHER LANGUAGE BINDINGS"
.IX Header "OTHER LANGUAGE BINDINGS"
Libev does not offer other language bindings itself, but bindings for a
-numbe rof languages exist in the form of third-party packages. If you know
+number of languages exist in the form of third-party packages. If you know
any interesting language binding in addition to the ones listed here, drop
me a note.
.IP "Perl" 4
@@ -2730,12 +2730,20 @@ there are additional modules that implement libev-compatible interfaces
to \f(CW\*(C`libadns\*(C'\fR (\f(CW\*(C`EV::ADNS\*(C'\fR), \f(CW\*(C`Net::SNMP\*(C'\fR (\f(CW\*(C`Net::SNMP::EV\*(C'\fR) and the
\&\f(CW\*(C`libglib\*(C'\fR event core (\f(CW\*(C`Glib::EV\*(C'\fR and \f(CW\*(C`EV::Glib\*(C'\fR).
.Sp
-It can be found and installed via \s-1CPAN\s0, its homepage is found at
+It can be found and installed via \s-1CPAN\s0, its homepage is at
<http://software.schmorp.de/pkg/EV>.
+.IP "Python" 4
+.IX Item "Python"
+Python bindings can be found at <http://code.google.com/p/pyev/>. It
+seems to be quite complete and well-documented. Note, however, that the
+patch they require for libev is outright dangerous as it breaks the \s-1ABI\s0
+for everybody else, and therefore, should never be applied in an installed
+libev (if python requires an incompatible \s-1ABI\s0 then it needs to embed
+libev).
.IP "Ruby" 4
.IX Item "Ruby"
Tony Arcieri has written a ruby extension that offers access to a subset
-of the libev \s-1API\s0 and adds filehandle abstractions, asynchronous \s-1DNS\s0 and
+of the libev \s-1API\s0 and adds file handle abstractions, asynchronous \s-1DNS\s0 and
more on top of it. It can be found via gem servers. Its homepage is at
<http://rev.rubyforge.org/>.
.IP "D" 4
@@ -2744,7 +2752,7 @@ Leandro Lucarella has written a D language binding (\fIev.d\fR) for libev, to
be found at <http://git.llucax.com.ar/?p=software/ev.d.git;a=summary>.
.SH "MACRO MAGIC"
.IX Header "MACRO MAGIC"
-Libev can be compiled with a variety of options, the most fundamantal
+Libev can be compiled with a variety of options, the most fundamental
of which is \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. This option determines whether (most)
functions and callbacks have an initial \f(CW\*(C`struct ev_loop *\*(C'\fR argument.
.PP
@@ -2758,9 +2766,9 @@ loop argument\*(R"). The \f(CW\*(C`EV_A\*(C'\fR form is used when this is the so
\&\f(CW\*(C`EV_A_\*(C'\fR is used when other arguments are following. Example:
.Sp
.Vb 3
-\& ev_unref (EV_A);
-\& ev_timer_add (EV_A_ watcher);
-\& ev_loop (EV_A_ 0);
+\& ev_unref (EV_A);
+\& ev_timer_add (EV_A_ watcher);
+\& ev_loop (EV_A_ 0);
.Ve
.Sp
It assumes the variable \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR is in scope,
@@ -2773,11 +2781,11 @@ loop parameter\*(R"). The \f(CW\*(C`EV_P\*(C'\fR form is used when this is the s
\&\f(CW\*(C`EV_P_\*(C'\fR is used when other parameters are following. Example:
.Sp
.Vb 2
-\& // this is how ev_unref is being declared
-\& static void ev_unref (EV_P);
+\& // this is how ev_unref is being declared
+\& static void ev_unref (EV_P);
\&
-\& // this is how you can declare your typical callback
-\& static void cb (EV_P_ ev_timer *w, int revents)
+\& // this is how you can declare your typical callback
+\& static void cb (EV_P_ ev_timer *w, int revents)
.Ve
.Sp
It declares a parameter \f(CW\*(C`loop\*(C'\fR of type \f(CW\*(C`struct ev_loop *\*(C'\fR, quite
@@ -2803,16 +2811,16 @@ macros so it will work regardless of whether multiple loops are supported
or not.
.PP
.Vb 5
-\& static void
-\& check_cb (EV_P_ ev_timer *w, int revents)
-\& {
-\& ev_check_stop (EV_A_ w);
-\& }
+\& static void
+\& check_cb (EV_P_ ev_timer *w, int revents)
+\& {
+\& ev_check_stop (EV_A_ w);
+\& }
\&
-\& ev_check check;
-\& ev_check_init (&check, check_cb);
-\& ev_check_start (EV_DEFAULT_ &check);
-\& ev_loop (EV_DEFAULT_ 0);
+\& ev_check check;
+\& ev_check_init (&check, check_cb);
+\& ev_check_start (EV_DEFAULT_ &check);
+\& ev_loop (EV_DEFAULT_ 0);
.Ve
.SH "EMBEDDING"
.IX Header "EMBEDDING"
@@ -2828,7 +2836,7 @@ libev somewhere in your source tree).
.Sh "\s-1FILESETS\s0"
.IX Subsection "FILESETS"
Depending on what features you need you need to include one or more sets of files
-in your app.
+in your application.
.PP
\fI\s-1CORE\s0 \s-1EVENT\s0 \s-1LOOP\s0\fR
.IX Subsection "CORE EVENT LOOP"
@@ -2837,8 +2845,8 @@ To include only the libev core (all the \f(CW\*(C`ev_*\*(C'\fR functions), with
configuration (no autoconf):
.PP
.Vb 2
-\& #define EV_STANDALONE 1
-\& #include "ev.c"
+\& #define EV_STANDALONE 1
+\& #include "ev.c"
.Ve
.PP
This will automatically include \fIev.h\fR, too, and should be done in a
@@ -2848,8 +2856,8 @@ done by writing a wrapper around \fIev.h\fR that you can include instead and
where you can put other configuration options):
.PP
.Vb 2
-\& #define EV_STANDALONE 1
-\& #include "ev.h"
+\& #define EV_STANDALONE 1
+\& #include "ev.h"
.Ve
.PP
Both header files and implementation files can be compiled with a \*(C+
@@ -2860,18 +2868,18 @@ You need the following files in your source tree, or in a directory
in your include path (e.g. in libev/ when using \-Ilibev):
.PP
.Vb 4
-\& ev.h
-\& ev.c
-\& ev_vars.h
-\& ev_wrap.h
+\& ev.h
+\& ev.c
+\& ev_vars.h
+\& ev_wrap.h
\&
-\& ev_win32.c required on win32 platforms only
+\& ev_win32.c required on win32 platforms only
\&
-\& ev_select.c only when select backend is enabled (which is enabled by default)
-\& ev_poll.c only when poll backend is enabled (disabled by default)
-\& ev_epoll.c only when the epoll backend is enabled (disabled by default)
-\& ev_kqueue.c only when the kqueue backend is enabled (disabled by default)
-\& ev_port.c only when the solaris port backend is enabled (disabled by default)
+\& ev_select.c only when select backend is enabled (which is enabled by default)
+\& ev_poll.c only when poll backend is enabled (disabled by default)
+\& ev_epoll.c only when the epoll backend is enabled (disabled by default)
+\& ev_kqueue.c only when the kqueue backend is enabled (disabled by default)
+\& ev_port.c only when the solaris port backend is enabled (disabled by default)
.Ve
.PP
\&\fIev.c\fR includes the backend files directly when enabled, so you only need
@@ -2883,13 +2891,13 @@ to compile this single file.
To include the libevent compatibility \s-1API\s0, also include:
.PP
.Vb 1
-\& #include "event.c"
+\& #include "event.c"
.Ve
.PP
in the file including \fIev.c\fR, and:
.PP
.Vb 1
-\& #include "event.h"
+\& #include "event.h"
.Ve
.PP
in the files that want to use the libevent \s-1API\s0. This also includes \fIev.h\fR.
@@ -2897,14 +2905,14 @@ in the files that want to use the libevent \s-1API\s0. This also includes \fIev.
You need the following additional files for this:
.PP
.Vb 2
-\& event.h
-\& event.c
+\& event.h
+\& event.c
.Ve
.PP
\fI\s-1AUTOCONF\s0 \s-1SUPPORT\s0\fR
.IX Subsection "AUTOCONF SUPPORT"
.PP
-Instead of using \f(CW\*(C`EV_STANDALONE=1\*(C'\fR and providing your config in
+Instead of using \f(CW\*(C`EV_STANDALONE=1\*(C'\fR and providing your configuration in
whatever way you want, you can also \f(CW\*(C`m4_include([libev.m4])\*(C'\fR in your
\&\fIconfigure.ac\fR and leave \f(CW\*(C`EV_STANDALONE\*(C'\fR undefined. \fIev.c\fR will then
include \fIconfig.h\fR and configure itself accordingly.
@@ -2912,12 +2920,12 @@ include \fIconfig.h\fR and configure itself accordingly.
For this of course you need the m4 file:
.PP
.Vb 1
-\& libev.m4
+\& libev.m4
.Ve
.Sh "\s-1PREPROCESSOR\s0 \s-1SYMBOLS/MACROS\s0"
.IX Subsection "PREPROCESSOR SYMBOLS/MACROS"
Libev can be configured via a variety of preprocessor symbols you have to
-define before including any of its files. The default in the absense of
+define before including any of its files. The default in the absence of
autoconf is noted for every option.
.IP "\s-1EV_STANDALONE\s0" 4
.IX Item "EV_STANDALONE"
@@ -2929,7 +2937,7 @@ supported). It will also not define any of the structs usually found in
.IP "\s-1EV_USE_MONOTONIC\s0" 4
.IX Item "EV_USE_MONOTONIC"
If defined to be \f(CW1\fR, libev will try to detect the availability of the
-monotonic clock option at both compiletime and runtime. Otherwise no use
+monotonic clock option at both compile time and runtime. Otherwise no use
of the monotonic clock option will be attempted. If you enable this, you
usually have to link against librt or something similar. Enabling it when
the functionality isn't available is safe, though, although you have
@@ -2938,8 +2946,8 @@ function is hiding in (often \fI\-lrt\fR).
.IP "\s-1EV_USE_REALTIME\s0" 4
.IX Item "EV_USE_REALTIME"
If defined to be \f(CW1\fR, libev will try to detect the availability of the
-realtime clock option at compiletime (and assume its availability at
-runtime if successful). Otherwise no use of the realtime clock option will
+real-time clock option at compile time (and assume its availability at
+runtime if successful). Otherwise no use of the real-time clock option will
be attempted. This effectively replaces \f(CW\*(C`gettimeofday\*(C'\fR by \f(CW\*(C`clock_get
(CLOCK_REALTIME, ...)\*(C'\fR and will not normally affect correctness. See the
note about libraries in the description of \f(CW\*(C`EV_USE_MONOTONIC\*(C'\fR, though.
@@ -2957,14 +2965,14 @@ If undefined, it will be enabled if the headers indicate GNU/Linux + Glibc
.IP "\s-1EV_USE_SELECT\s0" 4
.IX Item "EV_USE_SELECT"
If undefined or defined to be \f(CW1\fR, libev will compile in support for the
-\&\f(CW\*(C`select\*(C'\fR(2) backend. No attempt at autodetection will be done: if no
+\&\f(CW\*(C`select\*(C'\fR(2) backend. No attempt at auto-detection will be done: if no
other method takes over, select will be it. Otherwise the select backend
will not be compiled in.
.IP "\s-1EV_SELECT_USE_FD_SET\s0" 4
.IX Item "EV_SELECT_USE_FD_SET"
If defined to \f(CW1\fR, then the select backend will use the system \f(CW\*(C`fd_set\*(C'\fR
structure. This is useful if libev doesn't compile due to a missing
-\&\f(CW\*(C`NFDBITS\*(C'\fR or \f(CW\*(C`fd_mask\*(C'\fR definition or it misguesses the bitset layout on
+\&\f(CW\*(C`NFDBITS\*(C'\fR or \f(CW\*(C`fd_mask\*(C'\fR definition or it mis-guesses the bitset layout on
exotic systems. This usually limits the range of file descriptors to some
low limit such as 1024 or might have other limitations (winsocket only
allows 64 sockets). The \f(CW\*(C`FD_SETSIZE\*(C'\fR macro, set before compilation, might
@@ -3016,7 +3024,7 @@ otherwise another method will be used as fallback. This is the preferred
backend for Solaris 10 systems.
.IP "\s-1EV_USE_DEVPOLL\s0" 4
.IX Item "EV_USE_DEVPOLL"
-reserved for future expansion, works like the \s-1USE\s0 symbols above.
+Reserved for future expansion, works like the \s-1USE\s0 symbols above.
.IP "\s-1EV_USE_INOTIFY\s0" 4
.IX Item "EV_USE_INOTIFY"
If defined to be \f(CW1\fR, libev will compile in support for the Linux inotify
@@ -3031,7 +3039,7 @@ type is easily found in the C language, so you can provide your own type
that you know is safe for your purposes. It is used both for signal handler \*(L"locking\*(R"
as well as for signal and thread safety in \f(CW\*(C`ev_async\*(C'\fR watchers.
.Sp
-In the absense of this define, libev will use \f(CW\*(C`sig_atomic_t volatile\*(C'\fR
+In the absence of this define, libev will use \f(CW\*(C`sig_atomic_t volatile\*(C'\fR
(from \fIsignal.h\fR), which is usually good enough on most platforms.
.IP "\s-1EV_H\s0" 4
.IX Item "EV_H"
@@ -3076,8 +3084,8 @@ all the priorities, so having many of them (hundreds) uses a lot of space
and time, so using the defaults of five priorities (\-2 .. +2) is usually
fine.
.Sp
-If your embedding app does not need any priorities, defining these both to
-\&\f(CW0\fR will save some memory and cpu.
+If your embedding application does not need any priorities, defining these both to
+\&\f(CW0\fR will save some memory and \s-1CPU\s0.
.IP "\s-1EV_PERIODIC_ENABLE\s0" 4
.IX Item "EV_PERIODIC_ENABLE"
If undefined or defined to be \f(CW1\fR, then periodic timers are supported. If
@@ -3108,7 +3116,7 @@ defined to be \f(CW0\fR, then they are not.
.IX Item "EV_MINIMAL"
If you need to shave off some kilobytes of code at the expense of some
speed, define this symbol to \f(CW1\fR. Currently this is used to override some
-inlining decisions, saves roughly 30% codesize of amd64. It also selects a
+inlining decisions, saves roughly 30% code size on amd64. It also selects a
much smaller 2\-heap for timer management over the default 4\-heap.
.IP "\s-1EV_PID_HASHSIZE\s0" 4
.IX Item "EV_PID_HASHSIZE"
@@ -3128,7 +3136,7 @@ two).
Heaps are not very cache-efficient. To improve the cache-efficiency of the
timer and periodics heap, libev uses a 4\-heap when this symbol is defined
to \f(CW1\fR. The 4\-heap uses more complicated (longer) code but has
-noticably faster performance with many (thousands) of watchers.
+noticeably faster performance with many (thousands) of watchers.
.Sp
The default is \f(CW1\fR unless \f(CW\*(C`EV_MINIMAL\*(C'\fR is set in which case it is \f(CW0\fR
(disabled).
@@ -3139,7 +3147,7 @@ timer and periodics heap, libev can cache the timestamp (\fIat\fR) within
the heap structure (selected by defining \f(CW\*(C`EV_HEAP_CACHE_AT\*(C'\fR to \f(CW1\fR),
which uses 8\-12 bytes more per watcher and a few hundred bytes more code,
but avoids random read accesses on heap changes. This improves performance
-noticably with with many (hundreds) of watchers.
+noticeably with with many (hundreds) of watchers.
.Sp
The default is \f(CW1\fR unless \f(CW\*(C`EV_MINIMAL\*(C'\fR is set in which case it is \f(CW0\fR
(disabled).
@@ -3165,9 +3173,9 @@ though, and it must be identical each time.
For example, the perl \s-1EV\s0 module uses something like this:
.Sp
.Vb 3
-\& #define EV_COMMON \e
-\& SV *self; /* contains this struct */ \e
-\& SV *cb_sv, *fh /* note no trailing ";" */
+\& #define EV_COMMON \e
+\& SV *self; /* contains this struct */ \e
+\& SV *cb_sv, *fh /* note no trailing ";" */
.Ve
.IP "\s-1EV_CB_DECLARE\s0 (type)" 4
.IX Item "EV_CB_DECLARE (type)"
@@ -3185,18 +3193,18 @@ avoid the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument in all cases, or
method calls instead of plain function calls in \*(C+.
.Sh "\s-1EXPORTED\s0 \s-1API\s0 \s-1SYMBOLS\s0"
.IX Subsection "EXPORTED API SYMBOLS"
-If you need to re-export the \s-1API\s0 (e.g. via a dll) and you need a list of
+If you need to re-export the \s-1API\s0 (e.g. via a \s-1DLL\s0) and you need a list of
exported symbols, you can use the provided \fISymbol.*\fR files which list
all public symbols, one per line:
.PP
.Vb 2
-\& Symbols.ev for libev proper
-\& Symbols.event for the libevent emulation
+\& Symbols.ev for libev proper
+\& Symbols.event for the libevent emulation
.Ve
.PP
This can also be used to rename all public symbols to avoid clashes with
multiple versions of libev linked together (which is obviously bad in
-itself, but sometimes it is inconvinient to avoid this).
+itself, but sometimes it is inconvenient to avoid this).
.PP
A sed command like this will create wrapper \f(CW\*(C`#define\*(C'\fR's that you need to
include before including \fIev.h\fR:
@@ -3227,30 +3235,30 @@ The usage in rxvt-unicode is simpler. It has a \fIev_cpp.h\fR header file
that everybody includes and which overrides some configure choices:
.PP
.Vb 9
-\& #define EV_MINIMAL 1
-\& #define EV_USE_POLL 0
-\& #define EV_MULTIPLICITY 0
-\& #define EV_PERIODIC_ENABLE 0
-\& #define EV_STAT_ENABLE 0
-\& #define EV_FORK_ENABLE 0
-\& #define EV_CONFIG_H <config.h>
-\& #define EV_MINPRI 0
-\& #define EV_MAXPRI 0
+\& #define EV_MINIMAL 1
+\& #define EV_USE_POLL 0
+\& #define EV_MULTIPLICITY 0
+\& #define EV_PERIODIC_ENABLE 0
+\& #define EV_STAT_ENABLE 0
+\& #define EV_FORK_ENABLE 0
+\& #define EV_CONFIG_H <config.h>
+\& #define EV_MINPRI 0
+\& #define EV_MAXPRI 0
\&
-\& #include "ev++.h"
+\& #include "ev++.h"
.Ve
.PP
And a \fIev_cpp.C\fR implementation file that contains libev proper and is compiled:
.PP
.Vb 2
-\& #include "ev_cpp.h"
-\& #include "ev.c"
+\& #include "ev_cpp.h"
+\& #include "ev.c"
.Ve
.SH "THREADS AND COROUTINES"
.IX Header "THREADS AND COROUTINES"
.Sh "\s-1THREADS\s0"
.IX Subsection "THREADS"
-Libev itself is completely threadsafe, but it uses no locking. This
+Libev itself is completely thread-safe, but it uses no locking. This
means that you can use as many loops as you want in parallel, as long as
only one thread ever calls into one libev function with the same loop
parameter.
@@ -3265,7 +3273,7 @@ If you want to know which design is best for your problem, then I cannot
help you but by giving some generic advice:
.IP "\(bu" 4
most applications have a main thread: use the default libev loop
-in that thread, or create a seperate thread running only the default loop.
+in that thread, or create a separate thread running only the default loop.
.Sp
This helps integrating other libraries or software modules that use libev
themselves and don't care/know about threading.
@@ -3276,9 +3284,9 @@ Doing this is almost never wrong, sometimes a better-performance model
exists, but it is always a good start.
.IP "\(bu" 4
other models exist, such as the leader/follower pattern, where one
-loop is handed through multiple threads in a kind of round-robbin fashion.
+loop is handed through multiple threads in a kind of round-robin fashion.
.Sp
-Chosing a model is hard \- look around, learn, know that usually you cna do
+Choosing a model is hard \- look around, learn, know that usually you can do
better than you currently do :\-)
.IP "\(bu" 4
often you need to talk to some other thread which blocks in the
@@ -3286,7 +3294,7 @@ event loop \- \f(CW\*(C`ev_async\*(C'\fR watchers can be used to wake them up fr
threads safely (or from signal contexts...).
.Sh "\s-1COROUTINES\s0"
.IX Subsection "COROUTINES"
-Libev is much more accomodating to coroutines (\*(L"cooperative threads\*(R"):
+Libev is much more accommodating to coroutines (\*(L"cooperative threads\*(R"):
libev fully supports nesting calls to it's functions from different
coroutines (e.g. you can call \f(CW\*(C`ev_loop\*(C'\fR on the same loop from two
different coroutines and switch freely between both coroutines running the
@@ -3336,7 +3344,7 @@ fixed position in the storage array.
.IX Item "Each change on a file descriptor per loop iteration: O(number_of_watchers_for_this_fd)"
A change means an I/O watcher gets started or stopped, which requires
libev to recalculate its status (and possibly tell the kernel, depending
-on backend and wether \f(CW\*(C`ev_io_set\*(C'\fR was used).
+on backend and whether \f(CW\*(C`ev_io_set\*(C'\fR was used).
.IP "Activating one watcher (putting it into the pending state): O(1)" 4
.IX Item "Activating one watcher (putting it into the pending state): O(1)"
.PD 0
@@ -3355,11 +3363,11 @@ watchers becomes O(1) w.r.t. priority handling.
.IP "Processing signals: O(max_signal_number)" 4
.IX Item "Processing signals: O(max_signal_number)"
.PD
-Sending involves a syscall \fIiff\fR there were no other \f(CW\*(C`ev_async_send\*(C'\fR
+Sending involves a system call \fIiff\fR there were no other \f(CW\*(C`ev_async_send\*(C'\fR
calls in the current loop iteration. Checking for async and signal events
involves iterating over all running async watchers or all signal numbers.
-.SH "Win32 platform limitations and workarounds"
-.IX Header "Win32 platform limitations and workarounds"
+.SH "WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS"
+.IX Header "WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS"
Win32 doesn't support any of the standards (e.g. \s-1POSIX\s0) that libev
requires, and its I/O model is fundamentally incompatible with the \s-1POSIX\s0
model. Libev still offers limited functionality on this platform in
@@ -3375,28 +3383,55 @@ way (note also that glib is the slowest event library known to man).
There is no supported compilation method available on windows except
embedding it into other applications.
.PP
+Not a libev limitation but worth mentioning: windows apparently doesn't
+accept large writes: instead of resulting in a partial write, windows will
+either accept everything or return \f(CW\*(C`ENOBUFS\*(C'\fR if the buffer is too large,
+so make sure you only write small amounts into your sockets (less than a
+megabyte seems safe, but thsi apparently depends on the amount of memory
+available).
+.PP
Due to the many, low, and arbitrary limits on the win32 platform and
the abysmal performance of winsockets, using a large number of sockets
is not recommended (and not reasonable). If your program needs to use
more than a hundred or so sockets, then likely it needs to use a totally
different implementation for windows, as libev offers the \s-1POSIX\s0 readiness
notification model, which cannot be implemented efficiently on windows
-(microsoft monopoly games).
+(Microsoft monopoly games).
+.PP
+A typical way to use libev under windows is to embed it (see the embedding
+section for details) and use the following \fIevwrap.h\fR header file instead
+of \fIev.h\fR:
+.PP
+.Vb 2
+\& #define EV_STANDALONE /* keeps ev from requiring config.h */
+\& #define EV_SELECT_IS_WINSOCKET 1 /* configure libev for windows select */
+\&
+\& #include "ev.h"
+.Ve
+.PP
+And compile the following \fIevwrap.c\fR file into your project (make sure
+you do \fInot\fR compile the \fIev.c\fR or any other embedded soruce files!):
+.PP
+.Vb 2
+\& #include "evwrap.h"
+\& #include "ev.c"
+.Ve
.IP "The winsocket select function" 4
.IX Item "The winsocket select function"
The winsocket \f(CW\*(C`select\*(C'\fR function doesn't follow \s-1POSIX\s0 in that it
requires socket \fIhandles\fR and not socket \fIfile descriptors\fR (it is
also extremely buggy). This makes select very inefficient, and also
-requires a mapping from file descriptors to socket handles. See the
+requires a mapping from file descriptors to socket handles (the Microsoft
+C runtime provides the function \f(CW\*(C`_open_osfhandle\*(C'\fR for this). See the
discussion of the \f(CW\*(C`EV_SELECT_USE_FD_SET\*(C'\fR, \f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR and
\&\f(CW\*(C`EV_FD_TO_WIN32_HANDLE\*(C'\fR preprocessor symbols for more info.
.Sp
-The configuration for a \*(L"naked\*(R" win32 using the microsoft runtime
+The configuration for a \*(L"naked\*(R" win32 using the Microsoft runtime
libraries and raw winsocket select is:
.Sp
.Vb 2
-\& #define EV_USE_SELECT 1
-\& #define EV_SELECT_IS_WINSOCKET 1 /* forces EV_SELECT_USE_FD_SET, too */
+\& #define EV_USE_SELECT 1
+\& #define EV_SELECT_IS_WINSOCKET 1 /* forces EV_SELECT_USE_FD_SET, too */
.Ve
.Sp
Note that winsockets handling of fd sets is O(n), so you can easily get a
@@ -3407,7 +3442,7 @@ Windows has numerous arbitrary (and low) limits on things.
.Sp
Early versions of winsocket's select only supported waiting for a maximum
of \f(CW64\fR handles (probably owning to the fact that all windows kernels
-can only wait for \f(CW64\fR things at the same time internally; microsoft
+can only wait for \f(CW64\fR things at the same time internally; Microsoft
recommends spawning a chain of threads and wait for 63 handles and the
previous thread in each. Great).
.Sp
@@ -3416,11 +3451,11 @@ to some high number (e.g. \f(CW2048\fR) before compiling the winsocket select
call (which might be in libev or elsewhere, for example, perl does its own
select emulation on windows).
.Sp
-Another limit is the number of file descriptors in the microsoft runtime
+Another limit is the number of file descriptors in the Microsoft runtime
libraries, which by default is \f(CW64\fR (there must be a hidden \fI64\fR fetish
-or something like this inside microsoft). You can increase this by calling
+or something like this inside Microsoft). You can increase this by calling
\&\f(CW\*(C`_setmaxstdio\*(C'\fR, which can increase this limit to \f(CW2048\fR (another
-arbitrary limit), but is broken in many versions of the microsoft runtime
+arbitrary limit), but is broken in many versions of the Microsoft runtime
libraries.
.Sp
This might get you to about \f(CW512\fR or \f(CW2048\fR sockets (depending on
@@ -3431,6 +3466,14 @@ calling select (O(nA\*^X)) will likely make this unworkable.
.IX Header "PORTABILITY REQUIREMENTS"
In addition to a working ISO-C implementation, libev relies on a few
additional extensions:
+.ie n .IP """void (*)(ev_watcher_type *, int revents)""\fR must have compatible calling conventions regardless of \f(CW""ev_watcher_type *""." 4
+.el .IP "\f(CWvoid (*)(ev_watcher_type *, int revents)\fR must have compatible calling conventions regardless of \f(CWev_watcher_type *\fR." 4
+.IX Item "void (*)(ev_watcher_type *, int revents) must have compatible calling conventions regardless of ev_watcher_type *."
+Libev assumes not only that all watcher pointers have the same internal
+structure (guaranteed by \s-1POSIX\s0 but not by \s-1ISO\s0 C for example), but it also
+assumes that the same (machine) code can be used to call any watcher
+callback: The watcher callbacks have different type signatures, but libev
+calls them using an \f(CW\*(C`ev_watcher *\*(C'\fR internally.
.ie n .IP """sig_atomic_t volatile"" must be thread-atomic as well" 4
.el .IP "\f(CWsig_atomic_t volatile\fR must be thread-atomic as well" 4
.IX Item "sig_atomic_t volatile must be thread-atomic as well"
@@ -3477,14 +3520,14 @@ scared by this.
However, these are unavoidable for many reasons. For one, each compiler
has different warnings, and each user has different tastes regarding
warning options. \*(L"Warn-free\*(R" code therefore cannot be a goal except when
-targetting a specific compiler and compiler-version.
+targeting a specific compiler and compiler-version.
.PP
Another reason is that some compiler warnings require elaborate
workarounds, or other changes to the code that make it less clear and less
maintainable.
.PP
And of course, some compiler warnings are just plain stupid, or simply
-wrong (because they don't actually warn about the cindition their message
+wrong (because they don't actually warn about the condition their message
seems to warn about).
.PP
While libev is written to generate as few warnings as possible,
@@ -3506,7 +3549,7 @@ in libev, then check twice: If valgrind reports something like:
\& ==2274== still reachable: 256 bytes in 1 blocks.
.Ve
.PP
-then there is no memory leak. Similarly, under some circumstances,
+Then there is no memory leak. Similarly, under some circumstances,
valgrind might report kernel bugs as if it were a bug in libev, or it
might be confused (it is a very good tool, but only a tool).
.PP
@@ -3524,6 +3567,6 @@ Marc Lehmann <libev@schmorp.de>.
.SH "POD ERRORS"
.IX Header "POD ERRORS"
Hey! \fBThe above document had some coding errors, which are explained below:\fR
-.IP "Around line 3107:" 4
-.IX Item "Around line 3107:"
+.IP "Around line 3116:" 4
+.IX Item "Around line 3116:"
You forgot a '=back' before '=head2'