pth_exit, pth_die, pth_catch - exit a pseudothread and exception handling |
#include <pthr_pseudothread.h> void pth_exit (pseudothread) __attribute__((noreturn)); #define pth_die(pth,msg) _pth_die ((pth), (msg), __FILE__, __LINE__) const char *pth_catch (pseudothread pth, void (*fn) (void *), void *data); |
pth_exit causes the current thread to exit immediately. Note: you cannot force another thread to exit by calling this function. If you try to do that, strange and undefined things are likely to happen. Only the currently running thread may call pth_exit on itself. |
pth_die is similar in concept to pth_exit, except that it throws an exception which may be caught by using the pth_catch function. The distinction between pth_die and pth_exit is the same as the distinction between the Perl functions die and exit, in as much as exit in Perl always exits the process immediately, and die in Perl generally exits the process immediately unless the programmer catches the exception with eval and handles it appropriately. |
pth_catch is used to catch exceptions thrown by pth_die. You give fn (function) and data arguments, and the function calls fn (data). If, during this call, the code calls pth_die, then the exception message is immediately returned from pth_catch. If the code runs successfully to completion, then pth_catch will return NULL. |
Exceptions may be nested. |
Note that pth_catch will not catch calls to pth_exit. |
Richard Jones <rich@annexia.org> |
GNU LGPL (see http://www.gnu.org/) |
pthrlib-3.0.3 |