Boost.Thread: how to query the state of a thread
{to moderator: sorry, picked the wrong sender address last time, this one is subscribed} Hi, looking through the docs I can't seem to find a way to query boost::thread whether it's still running or has terminated and if so if it's still joinable. Is that information available somehow or do I need to keep track myself? TIA, Malte
Malte Starostik wrote:
{to moderator: sorry, picked the wrong sender address last time, this one is subscribed}
Hi,
looking through the docs I can't seem to find a way to query boost::thread whether it's still running or has terminated and if so if it's still joinable. Is that information available somehow or do I need to keep track myself?
In general you can't know that a thread is still running, because it may exit immediately after you find that it is. As for joinability, it's currently the client's responsibility to ensure that it only attempts to join a thread once (but this may change). If you want to know whether a thread has finished its work without necessarily waiting for it to do so, you can find your own method for the thread to signal this (which should probably involve a condition variable). Ben.
participants (2)
-
Ben Hutchings
-
Malte Starostik