Re: [c++-pthreads] Re: C++ and POSIX Threads Mailing List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] Re: C++ and POSIX Threads Mailing List
- To: Schwarz Konrad <konrad.schwarz@xxxxxxxxxxx>
- Subject: Re: [c++-pthreads] Re: C++ and POSIX Threads Mailing List
- From: Matt Austern <austern@xxxxxxxxx>
- Date: Fri, 19 Dec 2003 10:28:46 -0800
On Dec 18, 2003, at 11:58 PM, Schwarz Konrad wrote:
Mark Mitchell posted the existance of this mailing list to
austin-group.
Although not a C++ programmer, I want to present my views on the
subject:
Pthreads cancelation and C++ exceptions have arisen in different
contexts.
Although Tru64 apparently unites the two, I believe this is not
necessary.
Pthread code that is aysnc-cancelation safe needs to take extra
precautions
(pushing and popping cancelation handlers). Why can't this
restriction be
extended to C++? I.e., C++ code that wishes to be async-cancelation
safe
can do the exact same thing as C code. This avoids all the thorny
issues
that, juding from the (few) mails I read from your archive, are nearly
impossible to solve.
The annoying issues include synchronous cancellation, not just
asynchronous. At the simplest level: the POSIX standard says
that read is a cancellation point and that fread might be one too.
The C++ standard says that fread does not throw exceptions,
and, while the C++ standard doesn't mention read, most C++
programmers would think it's reasonable to assume that read
doesn't throw exceptions either. If we decide that thread
cancellation results in something like an exception getting thrown
in the canceled thread, then we've got a problem.
One possible solution (perhaps overly drastic): in C++, eliminate
all cancelation points except for pthread_testcancel.
--Matt