From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2008-05-30 03:19:34
"Peter Dimov" <pdimov_at_[hidden]> writes:
> Anthony Williams:
>> I have thought about providing an "interrupt handle" which you can
>> obtain either from a boost::thread object, or by calling
>> boost::this_thread::get_interrupt_handle() or similar, in which case a
>> detached thread would be interruptible.
> At this point how far would you be from N2178? It does give you this exact
> functionality, and in addition, one gets always-joinable handles that keep
> referring to its thread unless assigned something else.
Well, the interface is rather different for one thing, N2178 being
primarily free functions operating on handles, rather than member
functions on a class.
Also, I quite like the single-ownership property of boost::thread and
"Detach" has a definite meaning, in that there is now no thread object
referencing a specific thread, and so it can not be joined. If you
have copyable handles then you cannot reasonably have detached threads
until all the handles have gone away, and even then if you can get one
back with self(), you cannot really have detached threads.
Then again, do we need detached threads?
With single-ownership (and no interruption_handles), as Howard says,
you know whether or not a thread can be interrupted. I'm not sure
whether or not this is important. I can see use cases for
this_thread::get_interruption_handle(), since it would allow a thread
to store it in a shared location for another thread to interrupt
it. However, you can probably achieve the same thing by providing a
function in that shared data that has access to the boost::thread
object in question.
-- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk