
"vicente.botet" <vicente.botet@wanadoo.fr> writes:
I'm working with a keep_alive mechanism. I need to interrupt threads that are considered 'dead'. I have access to the thread specific context using a map : boost::thread::id -> context. This mapping is modified by self registration from the thread. On the other side I need a boost::thread pointer to interrupt the thread.
With the current Boost.Thread interface, I don't see how I can get it either from the current thread or from the thread::id. Can I?
No, you can't get a pointer or reference to the boost::thread object for a thread from its ID. Firstly, there may not be one (e.g. the initial thread, or a detached thread), and secondly that would defeat the point of the separation. A boost::thread instance is a single-ownership object. In general it is not safe to access it from multiple threads. On the other hand, boost::thread::id values are just values, and can be freely copied around. Finally, if you move your thread between boost::thread objects, all your pointers would become invalid. Anthony -- Anthony Williams Author of C++ Concurrency in Action | http://www.manning.com/williams Custom Software Development | http://www.justsoftwaresolutions.co.uk Just Software Solutions Ltd, Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK