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

Comparing libev/ev.pod (file contents):
Revision 1.312 by root, Thu Oct 21 15:14:49 2010 UTC vs.
Revision 1.319 by root, Fri Oct 22 10:09:12 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 interetsing 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
213 assert (("sorry, no epoll, no sex", 214 assert (("sorry, no epoll, no sex",
214 ev_supported_backends () & EVBACKEND_EPOLL)); 215 ev_supported_backends () & EVBACKEND_EPOLL));
215 216
216=item unsigned int ev_recommended_backends () 217=item unsigned int ev_recommended_backends ()
217 218
218Return the set of all backends compiled into this binary of libev and also 219Return the set of all backends compiled into this binary of libev and
219recommended for this platform. This set is often smaller than the one 220also recommended for this platform, meaning it will work for most file
221descriptor types. This set is often smaller than the one returned by
220returned by C<ev_supported_backends>, as for example kqueue is broken on 222C<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 223and 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 224you know what you are doing). This is the set of backends that libev will
223libev will probe for if you specify no backends explicitly. 225probe for if you specify no backends explicitly.
224 226
225=item unsigned int ev_embeddable_backends () 227=item unsigned int ev_embeddable_backends ()
226 228
227Returns the set of backends that are embeddable in other event loops. This 229Returns the set of backends that are embeddable in other event loops. This
228is the theoretical, all-platform, value. To find which backends 230value is platform-specific but can include backends not available on the
229might be supported on the current system, you would need to look at 231current system. To find which embeddable backends might be supported on
230C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for 232the current system, you would need to look at C<ev_embeddable_backends ()
231recommended ones. 233& ev_supported_backends ()>, likewise for recommended ones.
232 234
233See the description of C<ev_embed> watchers for more info. 235See the description of C<ev_embed> watchers for more info.
234 236
235=item ev_set_allocator (void *(*cb)(void *ptr, long size)) [NOT REENTRANT] 237=item ev_set_allocator (void *(*cb)(void *ptr, long size)) [NOT REENTRANT]
236 238
908 910
909=item ev_invoke_pending (loop) 911=item ev_invoke_pending (loop)
910 912
911This call will simply invoke all pending watchers while resetting their 913This call will simply invoke all pending watchers while resetting their
912pending state. Normally, C<ev_run> does this automatically when required, 914pending state. Normally, C<ev_run> does this automatically when required,
913but when overriding the invoke callback this call comes handy. 915but when overriding the invoke callback this call comes handy. This
916function can be invoked from a watcher - this can be useful for example
917when you want to do some lengthy calculation and want to pass further
918event handling to another thread (you still have to make sure only one
919thread executes within C<ev_invoke_pending> or C<ev_run> of course).
914 920
915=item int ev_pending_count (loop) 921=item int ev_pending_count (loop)
916 922
917Returns the number of pending watchers - zero indicates that no watchers 923Returns the number of pending watchers - zero indicates that no watchers
918are pending. 924are pending.
4527=head3 C<kqueue> is buggy 4533=head3 C<kqueue> is buggy
4528 4534
4529The kqueue syscall is broken in all known versions - most versions support 4535The kqueue syscall is broken in all known versions - most versions support
4530only sockets, many support pipes. 4536only sockets, many support pipes.
4531 4537
4532Libev tries to work around this by not using C<kqueue> by default on 4538Libev 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 4539rotten platform, but of course you can still ask for it when creating a
4534a loop. 4540loop - embedding a socket-only kqueue loop into a select-based one is
4541probably going to work well.
4535 4542
4536=head3 C<poll> is buggy 4543=head3 C<poll> is buggy
4537 4544
4538Instead of fixing C<kqueue>, Apple replaced their (working) C<poll> 4545Instead of fixing C<kqueue>, Apple replaced their (working) C<poll>
4539implementation by something calling C<kqueue> internally around the 10.5.6 4546implementation by something calling C<kqueue> internally around the 10.5.6
4558 4565
4559=head3 C<errno> reentrancy 4566=head3 C<errno> reentrancy
4560 4567
4561The default compile environment on Solaris is unfortunately so 4568The default compile environment on Solaris is unfortunately so
4562thread-unsafe that you can't even use components/libraries compiled 4569thread-unsafe that you can't even use components/libraries compiled
4563without C<-D_REENTRANT> (as long as they use C<errno>), which, of course, 4570without C<-D_REENTRANT> in a threaded program, which, of course, isn't
4564isn't defined by default. 4571defined by default. A valid, if stupid, implementation choice.
4565 4572
4566If you want to use libev in threaded environments you have to make sure 4573If you want to use libev in threaded environments you have to make sure
4567it's compiled with C<_REENTRANT> defined. 4574it's compiled with C<_REENTRANT> defined.
4568 4575
4569=head3 Event port backend 4576=head3 Event port backend
4570 4577
4571The scalable event interface for Solaris is called "event ports". Unfortunately, 4578The scalable event interface for Solaris is called "event
4572this mechanism is very buggy. If you run into high CPU usage, your program 4579ports". Unfortunately, this mechanism is very buggy in all major
4580releases. 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 4581a 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 4582and latest kernel patches applied. No, I don't know which ones, but there
4575ones, but there are multiple ones. 4583are multiple ones to apply, and afterwards, event ports actually work
4584great.
4576 4585
4577If you can't get it to work, you can try running the program by setting 4586If 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 4587the environment variable C<LIBEV_FLAGS=3> to only allow C<poll> and
4579C<select> backends. 4588C<select> backends.
4580 4589
4581=head2 AIX POLL BUG 4590=head2 AIX POLL BUG
4582 4591
4583AIX unfortunately has a broken C<poll.h> header. Libev works around 4592AIX 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 4593this 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 4594compiled in), which normally isn't a big problem as C<select> works fine
4586with large bitsets, and AIX is dead anyway. 4595with large bitsets on AIX, and AIX is dead anyway.
4587 4596
4588=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS 4597=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS
4589 4598
4590=head3 General issues 4599=head3 General issues
4591 4600
4868 4877
4869=over 4 4878=over 4
4870 4879
4871=item active 4880=item active
4872 4881
4873A watcher is active as long as it has been started (has been attached to 4882A 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). 4883See L<WATCHER STATES> for details.
4875 4884
4876=item application 4885=item application
4877 4886
4878In this document, an application is whatever is using libev. 4887In this document, an application is whatever is using libev.
4888
4889=item backend
4890
4891The part of the code dealing with the operating system interfaces.
4879 4892
4880=item callback 4893=item callback
4881 4894
4882The address of a function that is called when some event has been 4895The address of a function that is called when some event has been
4883detected. Callbacks are being passed the event loop, the watcher that 4896detected. Callbacks are being passed the event loop, the watcher that
4884received the event, and the actual event bitset. 4897received the event, and the actual event bitset.
4885 4898
4886=item callback invocation 4899=item callback/watcher invocation
4887 4900
4888The act of calling the callback associated with a watcher. 4901The act of calling the callback associated with a watcher.
4889 4902
4890=item event 4903=item event
4891 4904
4910The model used to describe how an event loop handles and processes 4923The model used to describe how an event loop handles and processes
4911watchers and events. 4924watchers and events.
4912 4925
4913=item pending 4926=item pending
4914 4927
4915A watcher is pending as soon as the corresponding event has been detected, 4928A 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 4929detected. 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 4930
4922=item real time 4931=item real time
4923 4932
4924The physical time that is observed. It is apparently strictly monotonic :) 4933The physical time that is observed. It is apparently strictly monotonic :)
4925 4934
4932=item watcher 4941=item watcher
4933 4942
4934A data structure that describes interest in certain events. Watchers need 4943A data structure that describes interest in certain events. Watchers need
4935to be started (attached to an event loop) before they can receive events. 4944to be started (attached to an event loop) before they can receive events.
4936 4945
4937=item watcher invocation
4938
4939The act of calling the callback associated with a watcher.
4940
4941=back 4946=back
4942 4947
4943=head1 AUTHOR 4948=head1 AUTHOR
4944 4949
4945Marc Lehmann <libev@schmorp.de>, with repeated corrections by Mikael Magnusson. 4950Marc Lehmann <libev@schmorp.de>, with repeated corrections by Mikael Magnusson.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines