[c++-pthreads] What are the real issues?
Alexander Terekhov
boo at terekhov.de
Wed Jan 7 12:33:26 UTC 2004
Nathan Myers wrote:
[...]
> We have better prospects in C++, if we can, as it were, hitch the
> cancellation-safety wagon to the exception-safety horse. Well-written
> exception handling code (i.e. implemented mainly in destructors) is
> much less subject to rot, being exercised on each block exit. Many
> more people know how to write exception-safe C++ code than C
> cancellation-safe code. (I'm not sure I would be able to write the
> latter, maintainably. C simply lacks the tools for it.)
P in "pthreads" stands for POSIX, not C, I guess.
#define pthread_cleanup_push(routine, arg) \
{ \
ScopeGuard _guard = MakeObjGuard(arg, routine);
#define pthread_cleanup_pop(execute) \
if (!execute) _guard.Dismiss(); \
}
http://www.cuj.com/documents/s=8000/cujcexp1812alexandr
(Simplify Your Exception-Safe Code)
regards,
alexander.
More information about the c++-pthreads
mailing list