[thread] Test if a thread is running

boost = 1.54 OS = Windows 7 compiler = Visual Studio 2005 Hi, in order to test if a boost.thread is running I used timed_join as per http://stackoverflow.com/questions/1667420/how-can-i-tell-reliably-if-a-boos..., which recommended that I should be able to call timed_join with a wait time of 0 ie bool isThreadRunning = ! m_Thread.timed_join( boost::get_system_time() ); I have just upgraded to boost 1.54 to see that this no longer appears to work and that the timed_join function is being deprecated. Can you tell me how I should now check whether a thread is running please? Thanks, Patrick

Patrick Steele
in order to test if a boost.thread is running I used timed_join as per http://stackoverflow.com/questions/1667420/how-can-i-tell-reliably-if-a-boos..., which recommended that I should be able to call timed_join with a wait time of 0 ie bool isThreadRunning = ! m_Thread.timed_join( boost::get_system_time() ); I have just upgraded to boost 1.54 to see that this no longer appears to work and that the timed_join function is being deprecated. Can you tell me how I should now check whether a thread is running please?
In cases like this i use a flag that is set to "thread running" when its enters its run method and to "thread ended" when the thread leaves its run method; to signal a condition for another bookkeeper thread can be an option. All this depends on how accurate the answer has to be... regards Christoph

Thank you both for the help, joinable() seems to be exactly what I need :)
Patrick
On 8 October 2013 18:07,
Patrick Steele
writes: in order to test if a boost.thread is running I used timed_join as per
http://stackoverflow.com/questions/1667420/how-can-i-tell-reliably-if-a-boos... ,
which recommended that I should be able to call timed_join with a wait time of 0 ie bool isThreadRunning = ! m_Thread.timed_join( boost::get_system_time() ); I have just upgraded to boost 1.54 to see that this no longer appears to work and that the timed_join function is being deprecated. Can you tell me how I should now check whether a thread is running please?
In cases like this i use a flag that is set to "thread running" when its enters its run method and to "thread ended" when the thread leaves its run method; to signal a condition for another bookkeeper thread can be an option. All this depends on how accurate the answer has to be...
regards Christoph
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

What do you suggest instead then?
On 9 October 2013 14:22, TONGARI J
2013/10/9 Patrick Steele
Thank you both for the help, joinable() seems to be exactly what I need :)
I'm afraid not, a thread is still "joinable" after its end of execution, unless you "join" it.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Oct 8, 2013, at 12:15 PM, Patrick Steele wrote:
boost = 1.54 OS = Windows 7 compiler = Visual Studio 2005
Hi, in order to test if a boost.thread is running I used timed_join as per http://stackoverflow.com/questions/1667420/how-can-i-tell-reliably-if-a-boos..., which recommended that I should be able to call timed_join with a wait time of 0 ie bool isThreadRunning = ! m_Thread.timed_join( boost::get_system_time() ); I have just upgraded to boost 1.54 to see that this no longer appears to work and that the timed_join function is being deprecated. Can you tell me how I should now check whether a thread is running please?
Use the joinable() member function.
participants (4)
-
christoph.kliemt@pgxml.net
-
Kim Barrett
-
Patrick Steele
-
TONGARI J