Re: [c++-pthreads] What are the real issues?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] What are the real issues?
- To: Nathan Myers <ncm@xxxxxxxxxxx>
- Subject: Re: [c++-pthreads] What are the real issues?
- From: Alexander Terekhov <boo@xxxxxxxxxxx>
- Date: Wed, 07 Jan 2004 13:33:26 +0100
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.