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.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
4531=head3 C<kqueue> is buggy 4533=head3 C<kqueue> is buggy
4532 4534
4533The kqueue syscall is broken in all known versions - most versions support 4535The kqueue syscall is broken in all known versions - most versions support
4534only sockets, many support pipes. 4536only sockets, many support pipes.
4535 4537
4536Libev 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
4537this 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
4538a loop. 4540loop - embedding a socket-only kqueue loop into a select-based one is
4541probably going to work well.
4539 4542
4540=head3 C<poll> is buggy 4543=head3 C<poll> is buggy
4541 4544
4542Instead of fixing C<kqueue>, Apple replaced their (working) C<poll> 4545Instead of fixing C<kqueue>, Apple replaced their (working) C<poll>
4543implementation by something calling C<kqueue> internally around the 10.5.6 4546implementation by something calling C<kqueue> internally around the 10.5.6
4562 4565
4563=head3 C<errno> reentrancy 4566=head3 C<errno> reentrancy
4564 4567
4565The default compile environment on Solaris is unfortunately so 4568The default compile environment on Solaris is unfortunately so
4566thread-unsafe that you can't even use components/libraries compiled 4569thread-unsafe that you can't even use components/libraries compiled
4567without 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
4568isn't defined by default. 4571defined by default. A valid, if stupid, implementation choice.
4569 4572
4570If 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
4571it's compiled with C<_REENTRANT> defined. 4574it's compiled with C<_REENTRANT> defined.
4572 4575
4573=head3 Event port backend 4576=head3 Event port backend
4574 4577
4575The scalable event interface for Solaris is called "event ports". Unfortunately, 4578The scalable event interface for Solaris is called "event
4576this 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
4577freezes 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
4578all 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
4579ones, but there are multiple ones. 4583are multiple ones to apply, and afterwards, event ports actually work
4584great.
4580 4585
4581If 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
4582the 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
4583C<select> backends. 4588C<select> backends.
4584 4589
4585=head2 AIX POLL BUG 4590=head2 AIX POLL BUG
4586 4591
4587AIX unfortunately has a broken C<poll.h> header. Libev works around 4592AIX 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 4593this 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 4594compiled in), which normally isn't a big problem as C<select> works fine
4590with large bitsets, and AIX is dead anyway. 4595with large bitsets on AIX, and AIX is dead anyway.
4591 4596
4592=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS 4597=head2 WIN32 PLATFORM LIMITATIONS AND WORKAROUNDS
4593 4598
4594=head3 General issues 4599=head3 General issues
4595 4600
4872 4877
4873=over 4 4878=over 4
4874 4879
4875=item active 4880=item active
4876 4881
4877A 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.
4878an event loop) but not yet stopped (disassociated from the event loop). 4883See L<WATCHER STATES> for details.
4879 4884
4880=item application 4885=item application
4881 4886
4882In 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.
4883 4892
4884=item callback 4893=item callback
4885 4894
4886The 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
4887detected. Callbacks are being passed the event loop, the watcher that 4896detected. Callbacks are being passed the event loop, the watcher that
4888received the event, and the actual event bitset. 4897received the event, and the actual event bitset.
4889 4898
4890=item callback invocation 4899=item callback/watcher invocation
4891 4900
4892The act of calling the callback associated with a watcher. 4901The act of calling the callback associated with a watcher.
4893 4902
4894=item event 4903=item event
4895 4904
4914The model used to describe how an event loop handles and processes 4923The model used to describe how an event loop handles and processes
4915watchers and events. 4924watchers and events.
4916 4925
4917=item pending 4926=item pending
4918 4927
4919A watcher is pending as soon as the corresponding event has been detected, 4928A 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 4929detected. 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 4930
4926=item real time 4931=item real time
4927 4932
4928The physical time that is observed. It is apparently strictly monotonic :) 4933The physical time that is observed. It is apparently strictly monotonic :)
4929 4934
4936=item watcher 4941=item watcher
4937 4942
4938A data structure that describes interest in certain events. Watchers need 4943A data structure that describes interest in certain events. Watchers need
4939to 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.
4940 4945
4941=item watcher invocation
4942
4943The act of calling the callback associated with a watcher.
4944
4945=back 4946=back
4946 4947
4947=head1 AUTHOR 4948=head1 AUTHOR
4948 4949
4949Marc 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