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

Comparing libev/ev.pod (file contents):
Revision 1.400 by root, Mon Apr 2 23:46:11 2012 UTC vs.
Revision 1.401 by root, Wed Apr 18 06:06:04 2012 UTC

247the current system, you would need to look at C<ev_embeddable_backends () 247the current system, you would need to look at C<ev_embeddable_backends ()
248& ev_supported_backends ()>, likewise for recommended ones. 248& ev_supported_backends ()>, likewise for recommended ones.
249 249
250See the description of C<ev_embed> watchers for more info. 250See the description of C<ev_embed> watchers for more info.
251 251
252=item ev_set_allocator (void *(*cb)(void *ptr, long size)) 252=item ev_set_allocator (void *(*cb)(void *ptr, long size) throw ())
253 253
254Sets the allocation function to use (the prototype is similar - the 254Sets the allocation function to use (the prototype is similar - the
255semantics are identical to the C<realloc> C89/SuS/POSIX function). It is 255semantics are identical to the C<realloc> C89/SuS/POSIX function). It is
256used to allocate and free memory (no surprises here). If it returns zero 256used to allocate and free memory (no surprises here). If it returns zero
257when memory needs to be allocated (C<size != 0>), the library might abort 257when memory needs to be allocated (C<size != 0>), the library might abort
283 } 283 }
284 284
285 ... 285 ...
286 ev_set_allocator (persistent_realloc); 286 ev_set_allocator (persistent_realloc);
287 287
288=item ev_set_syserr_cb (void (*cb)(const char *msg)) 288=item ev_set_syserr_cb (void (*cb)(const char *msg) throw ())
289 289
290Set the callback function to call on a retryable system call error (such 290Set the callback function to call on a retryable system call error (such
291as failed select, poll, epoll_wait). The message is a printable string 291as failed select, poll, epoll_wait). The message is a printable string
292indicating the system call or subsystem causing the problem. If this 292indicating the system call or subsystem causing the problem. If this
293callback is set, then libev will expect it to remedy the situation, no 293callback is set, then libev will expect it to remedy the situation, no
1016invoke the actual watchers inside another context (another thread etc.). 1016invoke the actual watchers inside another context (another thread etc.).
1017 1017
1018If you want to reset the callback, use C<ev_invoke_pending> as new 1018If you want to reset the callback, use C<ev_invoke_pending> as new
1019callback. 1019callback.
1020 1020
1021=item ev_set_loop_release_cb (loop, void (*release)(EV_P), void (*acquire)(EV_P)) 1021=item ev_set_loop_release_cb (loop, void (*release)(EV_P) throw (), void (*acquire)(EV_P) throw ())
1022 1022
1023Sometimes you want to share the same loop between multiple threads. This 1023Sometimes you want to share the same loop between multiple threads. This
1024can be done relatively simply by putting mutex_lock/unlock calls around 1024can be done relatively simply by putting mutex_lock/unlock calls around
1025each call to a libev function. 1025each call to a libev function.
1026 1026
3897 3897
3898=back 3898=back
3899 3899
3900=head1 C++ SUPPORT 3900=head1 C++ SUPPORT
3901 3901
3902=head2 C API
3903
3904The normal C API should work fine when used from C++: both ev.h and the
3905libev sources can be compiled as C++. Therefore, code that uses the C API
3906will work fine.
3907
3908Proper exception specifications might have to be added to callbacks passed
3909to libev: exceptions may be thrown only from watcher callbacks, all
3910other callbacks (allocator, syserr, loop acquire/release and periodioc
3911reschedule callbacks) must not throw exceptions, and might need a C<throw
3912()> specification. If you have code that needs to be compiled as both C
3913and C++ you can use the C<EV_THROW> macro for this:
3914
3915 static void
3916 fatal_error (const char *msg) EV_THROW
3917 {
3918 perror (msg);
3919 abort ();
3920 }
3921
3922 ...
3923 ev_set_syserr_cb (fatal_error);
3924
3925The only API functions that can currently throw exceptions are C<ev_run>,
3926C<ev_inoke> and C<ev_invoke_pending>.
3927
3928Throwing exceptions in watcher callbacks is only supported if libev itself
3929is compiled with a C++ compiler or your C and C++ environments allow
3930throwing exceptions through C libraries (most do).
3931
3932=head2 C++ API
3933
3902Libev comes with some simplistic wrapper classes for C++ that mainly allow 3934Libev comes with some simplistic wrapper classes for C++ that mainly allow
3903you to use some convenience methods to start/stop watchers and also change 3935you to use some convenience methods to start/stop watchers and also change
3904the callback model to a model using method callbacks on objects. 3936the callback model to a model using method callbacks on objects.
3905 3937
3906To use it, 3938To use it,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines