From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2007-03-26 17:26:44
> On Mar 26, 2007, at 2:04 PM, Peter Dimov wrote:
>> Howard Hinnant wrote:
>>> Fair point. Perhaps we should go back to a more fundamental
>>> std::thread t(f);
>>> t.cancel(); // Logically is this a const or non-const operation on
>>> the thread executing t/f?
>> I prefer to first ask "does it matter"? If you can't observe the
>> state of t and if you are assured that t.cancel is valid no matter
>> what else
>> is going on with t, what difference does a const/non-const label
>> make to the
>> external observer?
>> (Internally there is a flag being set, of course.)
> I believe it matters because other threads can detect whether the
> child thread has been canceled or not. Canceled may be a valid
> state. But it is a different and detectable state.
Perhaps shared_ptr/weak_ptr is a good analogy. I can have shared_ptr<int
const>, and if this is the last reference to expire it'll delete the int
(despite that mutable operations on the int are disallowed.) I can also have
a weak_ptr<int const> to the same object, and I can detect the fact that it
has been destroyed. Yet the object has no "destroyed" state.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk