Boost logo

Boost :

Subject: Re: [boost] [1.44] Beta progress?
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2010-07-26 16:11:49


David Abrahams <dave_at_[hidden]> writes:

> At Mon, 26 Jul 2010 15:01:40 +0100,
> Anthony Williams wrote:
>>
>> > Is pthread_cancel() still a no go to be used in threads::interrupt
>> > implementation?
>>
>> pthread_cancel is no-go because it has different semantics and cannot be
>> translated into an exception.
>
> If you mean that its semantics are different because pthread_cancel is
> intended to be an unstoppable, non-ignorable command, but someone can
> always do a catch(...){}, I think that's silly (and I've made that
> clear to the Posix people—I'm not just picking on you). Even in the
> `C' world there's nothing to stop me from either a) disabling
> cancellation or b) doing something in a cancellation handler that
> never terminates (including re-trying whatever operation was
> cancelled).

In principle, I agree. pthread_cancel should be usable as the basis for,
and interoperable with boost::thread::interrupt().

However, in practice it is not. I am not aware of any platforms where I
can cleanly catch a cancellation from pthread_cancel and translate it
into a boost::thread_interrupted exception. If I figure out a way, I'll
gladly use it.

Anthony

-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk