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

Comparing libev/ev.pod (file contents):
Revision 1.185 by root, Tue Sep 23 09:13:59 2008 UTC vs.
Revision 1.186 by root, Wed Sep 24 07:56:14 2008 UTC

214C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for 214C<ev_embeddable_backends () & ev_supported_backends ()>, likewise for
215recommended ones. 215recommended ones.
216 216
217See the description of C<ev_embed> watchers for more info. 217See the description of C<ev_embed> watchers for more info.
218 218
219=item ev_set_allocator (void *(*cb)(void *ptr, long size)) 219=item ev_set_allocator (void *(*cb)(void *ptr, long size)) [NOT REENTRANT]
220 220
221Sets the allocation function to use (the prototype is similar - the 221Sets the allocation function to use (the prototype is similar - the
222semantics are identical to the C<realloc> C89/SuS/POSIX function). It is 222semantics are identical to the C<realloc> C89/SuS/POSIX function). It is
223used to allocate and free memory (no surprises here). If it returns zero 223used to allocate and free memory (no surprises here). If it returns zero
224when memory needs to be allocated (C<size != 0>), the library might abort 224when memory needs to be allocated (C<size != 0>), the library might abort
250 } 250 }
251 251
252 ... 252 ...
253 ev_set_allocator (persistent_realloc); 253 ev_set_allocator (persistent_realloc);
254 254
255=item ev_set_syserr_cb (void (*cb)(const char *msg)); 255=item ev_set_syserr_cb (void (*cb)(const char *msg)); [NOT REENTRANT]
256 256
257Set the callback function to call on a retryable system call error (such 257Set the callback function to call on a retryable system call error (such
258as failed select, poll, epoll_wait). The message is a printable string 258as failed select, poll, epoll_wait). The message is a printable string
259indicating the system call or subsystem causing the problem. If this 259indicating the system call or subsystem causing the problem. If this
260callback is set, then libev will expect it to remedy the situation, no 260callback is set, then libev will expect it to remedy the situation, no
3303 3303
3304=head1 THREADS AND COROUTINES 3304=head1 THREADS AND COROUTINES
3305 3305
3306=head2 THREADS 3306=head2 THREADS
3307 3307
3308Libev itself is thread-safe (unless the opposite is specifically 3308All libev functions are reentrant and thread-safe unless explicitly
3309documented for a function), but it uses no locking itself. This means that 3309documented otherwise, but it uses no locking itself. This means that you
3310you can use as many loops as you want in parallel, as long as only one 3310can use as many loops as you want in parallel, as long as there are no
3311thread ever calls into one libev function with the same loop parameter: 3311concurrent calls into any libev function with the same loop parameter
3312(C<ev_default_*> calls have an implicit default loop parameter, of
3312libev guarantees that different event loops share no data structures that 3313course): libev guarantees that different event loops share no data
3313need locking. 3314structures that need any locking.
3314 3315
3315Or to put it differently: calls with different loop parameters can be done 3316Or to put it differently: calls with different loop parameters can be done
3316concurrently from multiple threads, calls with the same loop parameter 3317concurrently from multiple threads, calls with the same loop parameter
3317must be done serially (but can be done from different threads, as long as 3318must be done serially (but can be done from different threads, as long as
3318only one thread ever is inside a call at any point in time, e.g. by using 3319only one thread ever is inside a call at any point in time, e.g. by using
3319a mutex per loop). 3320a mutex per loop).
3320 3321
3321Specifically to support threads (and signal handlers), libev implements 3322Specifically to support threads (and signal handlers), libev implements
3322so-called C<ev_async> watchers, which allow some limited form of 3323so-called C<ev_async> watchers, which allow some limited form of
3323concurrency on the same event loop. 3324concurrency on the same event loop, namely waking it up "from the
3325outside".
3324 3326
3325If you want to know which design (one loop, locking, or multiple loops 3327If you want to know which design (one loop, locking, or multiple loops
3326without or something else still) is best for your problem, then I cannot 3328without or something else still) is best for your problem, then I cannot
3327help you. I can give some generic advice however: 3329help you, but here is some generic advice:
3328 3330
3329=over 4 3331=over 4
3330 3332
3331=item * most applications have a main thread: use the default libev loop 3333=item * most applications have a main thread: use the default libev loop
3332in that thread, or create a separate thread running only the default loop. 3334in that thread, or create a separate thread running only the default loop.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines