ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.313 by root, Fri Oct 22 05:44:33 2010 UTC vs.
Revision 1.321 by sf-exg, Fri Oct 22 10:50:24 2010 UTC

124this argument. 124this argument.
125 125
126=head2 TIME REPRESENTATION 126=head2 TIME REPRESENTATION
127 127
128Libev represents time as a single floating point number, representing 128Libev represents time as a single floating point number, representing
129the (fractional) number of seconds since the (POSIX) epoch (in practise 129the (fractional) number of seconds since the (POSIX) epoch (in practice
130somewhere near the beginning of 1970, details are complicated, don't 130somewhere near the beginning of 1970, details are complicated, don't
131ask). This type is called C<ev_tstamp>, which is what you should use 131ask). This type is called C<ev_tstamp>, which is what you should use
132too. It usually aliases to the C<double> type in C. When you need to do 132too. It usually aliases to the C<double> type in C. When you need to do
133any calculations on it, you should treat it as some floating point value. 133any calculations on it, you should treat it as some floating point value.
134 134
165 165
166=item ev_tstamp ev_time () 166=item ev_tstamp ev_time ()
167 167
168Returns the current time as libev would use it. Please note that the 168Returns the current time as libev would use it. Please note that the
169C<ev_now> function is usually faster and also often returns the timestamp 169C<ev_now> function is usually faster and also often returns the timestamp
170you actually want to know. 170you actually want to know. Also interesting is the combination of
171C<ev_update_now> and C<ev_now>.
171 172
172=item ev_sleep (ev_tstamp interval) 173=item ev_sleep (ev_tstamp interval)
173 174
174Sleep for the given interval: The current thread will be blocked until 175Sleep for the given interval: The current thread will be blocked until
175either it is interrupted or the given time interval has passed. Basically 176either it is interrupted or the given time interval has passed. Basically
192as this indicates an incompatible change. Minor versions are usually 193as this indicates an incompatible change. Minor versions are usually
193compatible to older versions, so a larger minor version alone is usually 194compatible to older versions, so a larger minor version alone is usually
194not a problem. 195not a problem.
195 196
196Example: Make sure we haven't accidentally been linked against the wrong 197Example: Make sure we haven't accidentally been linked against the wrong
197version (note, however, that this will not detect ABI mismatches :). 198version (note, however, that this will not detect other ABI mismatches,
199such as LFS or reentrancy).
198 200
199 assert (("libev version mismatch", 201 assert (("libev version mismatch",
200 ev_version_major () == EV_VERSION_MAJOR 202 ev_version_major () == EV_VERSION_MAJOR
201 && ev_version_minor () >= EV_VERSION_MINOR)); 203 && ev_version_minor () >= EV_VERSION_MINOR));
202 204
213 assert (("sorry, no epoll, no sex", 215 assert (("sorry, no epoll, no sex",
214 ev_supported_backends () & EVBACKEND_EPOLL)); 216 ev_supported_backends () & EVBACKEND_EPOLL));
215 217
216=item unsigned int ev_recommended_backends () 218=item unsigned int ev_recommended_backends ()
217 219
218Return the set of all backends compiled into this binary of libev and also 220Return the set of all backends compiled into this binary of libev and
219recommended for this platform. This set is often smaller than the one 221also recommended for this platform, meaning it will work for most file
222descriptor types. This set is often smaller than the one returned by
220returned by C<ev_supported_backends>, as for example kqueue is broken on 223C<ev_supported_backends>, as for example kqueue is broken on most BSDs
221most BSDs and will not be auto-detected unless you explicitly request it 224and will not be auto-detected unless you explicitly request it (assuming
222(assuming you know what you are doing). This is the set of backends that 225you know what you are doing). This is the set of backends that libev will
223libev will probe for if you specify no backends explicitly. 226probe for if you specify no backends explicitly.
224 227
225=item unsigned int ev_embeddable_backends () 228=item unsigned int ev_embeddable_backends ()
226 229
227Returns the set of backends that are embeddable in other event loops. This 230Returns the set of backends that are embeddable in other event loops. This
228is the theoretical, all-platform, value. To find which backends 231value is platform-specific but can include backends not available on the
229might be supported on the current system, you would need to look at 232current system. To find which embeddable backends might be supported on
230C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for 233the current system, you would need to look at C<ev_embeddable_backends ()
231recommended ones. 234& ev_supported_backends ()>, likewise for recommended ones.
232 235
233See the description of C<ev_embed> watchers for more info. 236See the description of C<ev_embed> watchers for more info.
234 237
235=item ev_set_allocator (void *(*cb)(void *ptr, long size)) [NOT REENTRANT] 238=item ev_set_allocator (void *(*cb)(void *ptr, long size)) [NOT REENTRANT]
236 239
4531=head3 C<kqueue> is buggy 4534=head3 C<kqueue> is buggy
4532 4535
4533The kqueue syscall is broken in all known versions - most versions support 4536The kqueue syscall is broken in all known versions - most versions support
4534only sockets, many support pipes. 4537only sockets, many support pipes.
4535 4538
4536Libev tries to work around this by not using C<kqueue> by default on 4539Libev tries to work around this by not using C<kqueue> by default on this
4537this rotten platform, but of course you can still ask for it when creating 4540rotten platform, but of course you can still ask for it when creating a
4538a loop. 4541loop - embedding a socket-only kqueue loop into a select-based one is
4542probably going to work well.
4539 4543
4540=head3 C<poll> is buggy 4544=head3 C<poll> is buggy
4541 4545
4542Instead of fixing C<kqueue>, Apple replaced their (working) C<poll> 4546Instead of fixing C<kqueue>, Apple replaced their (working) C<poll>
4543implementation by something calling C<kqueue> internally around the 10.5.6 4547implementation by something calling C<kqueue> internally around the 10.5.6
4562 4566
4563=head3 C<errno> reentrancy 4567=head3 C<errno> reentrancy
4564 4568
4565The default compile environment on Solaris is unfortunately so 4569The default compile environment on Solaris is unfortunately so
4566thread-unsafe that you can't even use components/libraries compiled 4570thread-unsafe that you can't even use components/libraries compiled
4567without C<-D_REENTRANT> (as long as they use C<errno>), which, of course, 4571without C<-D_REENTRANT> in a threaded program, which, of course, isn't
4568isn't defined by default. 4572defined by default. A valid, if stupid, implementation choice.
4569 4573
4570If you want to use libev in threaded environments you have to make sure 4574If you want to use libev in threaded environments you have to make sure
4571it's compiled with C<_REENTRANT> defined. 4575it's compiled with C<_REENTRANT> defined.
4572 4576
4573=head3 Event port backend 4577=head3 Event port backend
4574 4578
4575The scalable event interface for Solaris is called "event ports". Unfortunately, 4579The scalable event interface for Solaris is called "event
4576this mechanism is very buggy. If you run into high CPU usage, your program 4580ports". Unfortunately, this mechanism is very buggy in all major
4581releases. If you run into high CPU usage, your program freezes or you get
4577freezes or you get a large number of spurious wakeups, make sure you have 4582a large number of spurious wakeups, make sure you have all the relevant
4578all the relevant and latest kernel patches applied. No, I don't know which 4583and latest kernel patches applied. No, I don't know which ones, but there
4579ones, but there are multiple ones. 4584are multiple ones to apply, and afterwards, event ports actually work
4585great.
4580 4586
4581If you can't get it to work, you can try running the program by setting 4587If you can't get it to work, you can try running the program by setting
4582the environment variable C<LIBEV_FLAGS=3> to only allow C<poll> and 4588the environment variable C<LIBEV_FLAGS=3> to only allow C<poll> and
4583C<select> backends. 4589C<select> backends.
4584 4590
4585=head2 AIX POLL BUG 4591=head2 AIX POLL BUG
4586 4592
4587AIX unfortunately has a broken C<poll.h> header. Libev works around 4593AIX unfortunately has a broken C<poll.h> header. Libev works around
4588this by trying to avoid the poll backend altogether (i.e. it's not even 4594this by trying to avoid the poll backend altogether (i.e. it's not even
4589compiled in), which normally isn't a big problem as C<select> works fine 4595compiled in), which normally isn't a big problem as C<select> works fine
4590with large bitsets, and AIX is dead anyway. 4596with large bitsets on AIX, and AIX is dead anyway.
4591 4597
4592=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS 4598=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS
4593 4599
4594=head3 General issues 4600=head3 General issues
4595 4601
4872 4878
4873=over 4 4879=over 4
4874 4880
4875=item active 4881=item active
4876 4882
4877A watcher is active as long as it has been started (has been attached to 4883A watcher is active as long as it has been started and not yet stopped.
4878an event loop) but not yet stopped (disassociated from the event loop). 4884See L<WATCHER STATES> for details.
4879 4885
4880=item application 4886=item application
4881 4887
4882In this document, an application is whatever is using libev. 4888In this document, an application is whatever is using libev.
4889
4890=item backend
4891
4892The part of the code dealing with the operating system interfaces.
4883 4893
4884=item callback 4894=item callback
4885 4895
4886The address of a function that is called when some event has been 4896The address of a function that is called when some event has been
4887detected. Callbacks are being passed the event loop, the watcher that 4897detected. Callbacks are being passed the event loop, the watcher that
4888received the event, and the actual event bitset. 4898received the event, and the actual event bitset.
4889 4899
4890=item callback invocation 4900=item callback/watcher invocation
4891 4901
4892The act of calling the callback associated with a watcher. 4902The act of calling the callback associated with a watcher.
4893 4903
4894=item event 4904=item event
4895 4905
4914The model used to describe how an event loop handles and processes 4924The model used to describe how an event loop handles and processes
4915watchers and events. 4925watchers and events.
4916 4926
4917=item pending 4927=item pending
4918 4928
4919A watcher is pending as soon as the corresponding event has been detected, 4929A watcher is pending as soon as the corresponding event has been
4920and stops being pending as soon as the watcher will be invoked or its 4930detected. See L<WATCHER STATES> for details.
4921pending status is explicitly cleared by the application.
4922
4923A watcher can be pending, but not active. Stopping a watcher also clears
4924its pending status.
4925 4931
4926=item real time 4932=item real time
4927 4933
4928The physical time that is observed. It is apparently strictly monotonic :) 4934The physical time that is observed. It is apparently strictly monotonic :)
4929 4935
4936=item watcher 4942=item watcher
4937 4943
4938A data structure that describes interest in certain events. Watchers need 4944A data structure that describes interest in certain events. Watchers need
4939to be started (attached to an event loop) before they can receive events. 4945to be started (attached to an event loop) before they can receive events.
4940 4946
4941=item watcher invocation
4942
4943The act of calling the callback associated with a watcher.
4944
4945=back 4947=back
4946 4948
4947=head1 AUTHOR 4949=head1 AUTHOR
4948 4950
4949Marc Lehmann <libev@schmorp.de>, with repeated corrections by Mikael Magnusson. 4951Marc Lehmann <libev@schmorp.de>, with repeated corrections by Mikael Magnusson.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines