thread-safety definition
David Abrahams
dave at boost-consulting.com
Thu Jan 8 15:32:11 UTC 2004
Dave Butenhof <David.Butenhof at hp.com> writes:
> David Abrahams wrote:
>
>>Mathieu Lacage <Mathieu.Lacage at sophia.inria.fr> writes:
>>
>>
>>>It looks like what everyone is trying to achieve here is a way for C++
>>> authors to write thread-safe libraries.
>>>
>>I think you missed something, or maybe the main thing. C++ authors
>>can already write thread-safe libraries.
>>
>>What I'm trying to achieve is to allow existing thread-safe library
>>code that wasn't written with POSIX cancellations in mind to be used
>>easily in a POSIX environment.
>>
>>
> Right. And I maintain that this is trivial AS LONG AS you can
> guarantee that threads running that unsafe code will never be
> cancelled. (This seems reasonable, since obviously threads running
> that code had never previously been subject to cancellation!) And it's
> IMPOSSIBLE if you cannot guarantee that.
Please don't shout, especially to emphasize something I disagree with
so fundamentally. ;-)
> The code must be analyzed and corrected, point by point; and the
> analysis (and possibly the correction as well) is easier if
> cancellation is a structured exception than if it's a return status
> handled in various "unique" ways by each routine.
If you make cancellations behave sufficiently like an ordinary C++
exception (either of Nathan's or Jason's models would do that I think)
then it's neither "IMPOSSIBLE" nor even difficult. A great deal of
thread-safe exception-safe C++ library code would behave perfectly
well under those conditions.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the c++-pthreads
mailing list