--- libev/ev.pod 2012/04/02 23:46:11 1.400 +++ libev/ev.pod 2012/04/18 06:06:04 1.401 @@ -249,7 +249,7 @@ See the description of C watchers for more info. -=item ev_set_allocator (void *(*cb)(void *ptr, long size)) +=item ev_set_allocator (void *(*cb)(void *ptr, long size) throw ()) Sets the allocation function to use (the prototype is similar - the semantics are identical to the C C89/SuS/POSIX function). It is @@ -285,7 +285,7 @@ ... ev_set_allocator (persistent_realloc); -=item ev_set_syserr_cb (void (*cb)(const char *msg)) +=item ev_set_syserr_cb (void (*cb)(const char *msg) throw ()) Set the callback function to call on a retryable system call error (such as failed select, poll, epoll_wait). The message is a printable string @@ -1018,7 +1018,7 @@ If you want to reset the callback, use C as new callback. -=item ev_set_loop_release_cb (loop, void (*release)(EV_P), void (*acquire)(EV_P)) +=item ev_set_loop_release_cb (loop, void (*release)(EV_P) throw (), void (*acquire)(EV_P) throw ()) Sometimes you want to share the same loop between multiple threads. This can be done relatively simply by putting mutex_lock/unlock calls around @@ -3899,6 +3899,38 @@ =head1 C++ SUPPORT +=head2 C API + +The normal C API should work fine when used from C++: both ev.h and the +libev sources can be compiled as C++. Therefore, code that uses the C API +will work fine. + +Proper exception specifications might have to be added to callbacks passed +to libev: exceptions may be thrown only from watcher callbacks, all +other callbacks (allocator, syserr, loop acquire/release and periodioc +reschedule callbacks) must not throw exceptions, and might need a C specification. If you have code that needs to be compiled as both C +and C++ you can use the C macro for this: + + static void + fatal_error (const char *msg) EV_THROW + { + perror (msg); + abort (); + } + + ... + ev_set_syserr_cb (fatal_error); + +The only API functions that can currently throw exceptions are C, +C and C. + +Throwing exceptions in watcher callbacks is only supported if libev itself +is compiled with a C++ compiler or your C and C++ environments allow +throwing exceptions through C libraries (most do). + +=head2 C++ API + Libev comes with some simplistic wrapper classes for C++ that mainly allow you to use some convenience methods to start/stop watchers and also change the callback model to a model using method callbacks on objects.