On Sun, 12 Sep 2010 06:52:49 +0200, Francesco Biscani
[...]
boost::thread t(...); // thread of execution runs bool running = t.joinable(); // thread of execution terminates (automatically) bool still_running = t.joinable();
Does joinable() return true in the first case and false in the second?
No, it will return true both times.
The documentation says that in the second case join() returns immediately. However I don't want to call join() because it would block in the first case. I would need to know in advance whether the thread of execution has terminated or not - this is exactly what I'd like boost::thread to tell me. :)
Maybe you can use boost::thread::timed_join() with a very low timeout (or even zero timeout, haven't checked if it works like that).
Thanks for your reply! Do you know whether the thread of execution is allowed to call boost::thread::detach()? Then it could detach itself from the boost::thread object before it terminates and boost::thread::joinable() should work? I'm not sure though if boost::thread is thread-safe? Boris