Re: [c++-pthreads] cancellation points report failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] cancellation points report failure



Ted Baker <baker@xxxxxxxxxx> writes:

> How do you propose to prevent cancelation occurring (i.e., the
> thread starts executing the cleanup routines and then exits) if a
> C++ library function uses an underlying C library call that is a
> thread cancelation point?
>
> Are you figuring on redoing all the libraries to avoid calls
> to such C functions?

One of us is very confused.  What you're talking about is the problem
we have today.  IIUC, Nathan was suggesting that read() should report
cancellation using the same means it uses to report failures to 'C'
programs, IOW, not by throwing an exception.  Maybe I've
misunderstood something?


>> >> One possible solution (perhaps overly drastic): in C++, eliminate
>> >> all cancelation points except for pthread_testcancel.
>> >
>> > Another would be for those functions identified as cancellation 
>> > points to report failure.  In particular, a read() call should return 
>> > immediately.  Existing (good) code has to handle normal failures 
>> > already.  Well-designed library code will propagate the failure up 
>> > to the point where a check for cancellation, and throw, may occur.  
>> 
>> Ingenious!  I'm not sure about all the implications, but I think we
>> should explore this idea further.  In hindsight, it's almost obvious:
>> a function should only report failure in one way.  Requiring
>> programmers to deal with exceptions *and* failure status makes the
>> whole thing unwieldy and error-prone.
>

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com