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

Comparing libev/ev.pod (file contents):
Revision 1.311 by root, Thu Oct 21 14:40:07 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
908 911
909=item ev_invoke_pending (loop) 912=item ev_invoke_pending (loop)
910 913
911This call will simply invoke all pending watchers while resetting their 914This call will simply invoke all pending watchers while resetting their
912pending state. Normally, C<ev_run> does this automatically when required, 915pending state. Normally, C<ev_run> does this automatically when required,
913but when overriding the invoke callback this call comes handy. 916but when overriding the invoke callback this call comes handy. This
917function can be invoked from a watcher - this can be useful for example
918when you want to do some lengthy calculation and want to pass further
919event handling to another thread (you still have to make sure only one
920thread executes within C<ev_invoke_pending> or C<ev_run> of course).
914 921
915=item int ev_pending_count (loop) 922=item int ev_pending_count (loop)
916 923
917Returns the number of pending watchers - zero indicates that no watchers 924Returns the number of pending watchers - zero indicates that no watchers
918are pending. 925are pending.
1159and call libev functions on it that are documented to work on active watchers. 1166and call libev functions on it that are documented to work on active watchers.
1160 1167
1161=item pending 1168=item pending
1162 1169
1163If a watcher is active and libev determines that an event it is interested 1170If a watcher is active and libev determines that an event it is interested
1164in has occured (such as a timer expiring), it will become pending. It will 1171in has occurred (such as a timer expiring), it will become pending. It will
1165stay in this pending state until either it is stopped or its callback is 1172stay in this pending state until either it is stopped or its callback is
1166about to be invoked, so it is not normally pending inside the watcher 1173about to be invoked, so it is not normally pending inside the watcher
1167callback. 1174callback.
1168 1175
1169The watcher might or might not be active while it is pending (for example, 1176The watcher might or might not be active while it is pending (for example,
4527=head3 C<kqueue> is buggy 4534=head3 C<kqueue> is buggy
4528 4535
4529The kqueue syscall is broken in all known versions - most versions support 4536The kqueue syscall is broken in all known versions - most versions support
4530only sockets, many support pipes. 4537only sockets, many support pipes.
4531 4538
4532Libev 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
4533this 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
4534a loop. 4541loop - embedding a socket-only kqueue loop into a select-based one is
4542probably going to work well.
4535 4543
4536=head3 C<poll> is buggy 4544=head3 C<poll> is buggy
4537 4545
4538Instead of fixing C<kqueue>, Apple replaced their (working) C<poll> 4546Instead of fixing C<kqueue>, Apple replaced their (working) C<poll>
4539implementation by something calling C<kqueue> internally around the 10.5.6 4547implementation by something calling C<kqueue> internally around the 10.5.6
4558 4566
4559=head3 C<errno> reentrancy 4567=head3 C<errno> reentrancy
4560 4568
4561The default compile environment on Solaris is unfortunately so 4569The default compile environment on Solaris is unfortunately so
4562thread-unsafe that you can't even use components/libraries compiled 4570thread-unsafe that you can't even use components/libraries compiled
4563without 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
4564isn't defined by default. 4572defined by default. A valid, if stupid, implementation choice.
4565 4573
4566If 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
4567it's compiled with C<_REENTRANT> defined. 4575it's compiled with C<_REENTRANT> defined.
4568 4576
4569=head3 Event port backend 4577=head3 Event port backend
4570 4578
4571The scalable event interface for Solaris is called "event ports". Unfortunately, 4579The scalable event interface for Solaris is called "event
4572this 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
4573freezes 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
4574all 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
4575ones, but there are multiple ones. 4584are multiple ones to apply, and afterwards, event ports actually work
4585great.
4576 4586
4577If 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
4578the 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
4579C<select> backends. 4589C<select> backends.
4580 4590
4581=head2 AIX POLL BUG 4591=head2 AIX POLL BUG
4582 4592
4583AIX unfortunately has a broken C<poll.h> header. Libev works around 4593AIX unfortunately has a broken C<poll.h> header. Libev works around
4584this 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
4585compiled 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
4586with large bitsets, and AIX is dead anyway. 4596with large bitsets on AIX, and AIX is dead anyway.
4587 4597
4588=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS 4598=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS
4589 4599
4590=head3 General issues 4600=head3 General issues
4591 4601
4868 4878
4869=over 4 4879=over 4
4870 4880
4871=item active 4881=item active
4872 4882
4873A 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.
4874an event loop) but not yet stopped (disassociated from the event loop). 4884See L<WATCHER STATES> for details.
4875 4885
4876=item application 4886=item application
4877 4887
4878In 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.
4879 4893
4880=item callback 4894=item callback
4881 4895
4882The 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
4883detected. Callbacks are being passed the event loop, the watcher that 4897detected. Callbacks are being passed the event loop, the watcher that
4884received the event, and the actual event bitset. 4898received the event, and the actual event bitset.
4885 4899
4886=item callback invocation 4900=item callback/watcher invocation
4887 4901
4888The act of calling the callback associated with a watcher. 4902The act of calling the callback associated with a watcher.
4889 4903
4890=item event 4904=item event
4891 4905
4910The model used to describe how an event loop handles and processes 4924The model used to describe how an event loop handles and processes
4911watchers and events. 4925watchers and events.
4912 4926
4913=item pending 4927=item pending
4914 4928
4915A watcher is pending as soon as the corresponding event has been detected, 4929A watcher is pending as soon as the corresponding event has been
4916and stops being pending as soon as the watcher will be invoked or its 4930detected. See L<WATCHER STATES> for details.
4917pending status is explicitly cleared by the application.
4918
4919A watcher can be pending, but not active. Stopping a watcher also clears
4920its pending status.
4921 4931
4922=item real time 4932=item real time
4923 4933
4924The physical time that is observed. It is apparently strictly monotonic :) 4934The physical time that is observed. It is apparently strictly monotonic :)
4925 4935
4932=item watcher 4942=item watcher
4933 4943
4934A data structure that describes interest in certain events. Watchers need 4944A data structure that describes interest in certain events. Watchers need
4935to 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.
4936 4946
4937=item watcher invocation
4938
4939The act of calling the callback associated with a watcher.
4940
4941=back 4947=back
4942 4948
4943=head1 AUTHOR 4949=head1 AUTHOR
4944 4950
4945Marc 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