[cpp-threads] Thread API interface tweaks

Peter Dimov pdimov at mmltd.net
Tue Aug 29 13:37:52 BST 2006


Alexander Terekhov wrote:
> On 8/29/06, Peter Dimov <pdimov at mmltd.net> wrote:
> [...]
>> The current design treats a cancellation exception no different than
>> any other exception; that is, operator() throws a cancellation
>> exception when the thread executing the task has been cancelled.
>>
>> This introduces an ambiguity since operator() can block and be itself
>> cancelled. That's why there is an explicit wait(); when it throws,
>> the waiting thread has been cancelled. After a successful wait(), if
>> operator() throws a cancellation exception, it has come from the
>> other side.
>
> And this introduces an ambiguity race. No?

Nope, operator() never blocks after wait() has finished, since there is a 
result/exception available. ready() is a postcondition of a successful 
wait().

> What about try_wait()? Does it throw cancel or not?

No, try_wait (spelled 'bool ready() const') is non-blocking and hence, 
non-cancellable. 




More information about the cpp-threads mailing list