How can I tell reliably if a boost thread has exited its run method?

后端 未结 7 1038
情歌与酒
情歌与酒 2020-12-01 13:40

I assumed joinable would indicate this, however, it does not seem to be the case.

In a worker class, I was trying to indicate that it was still processing through a

7条回答
  •  悲哀的现实
    2020-12-01 14:36

    Use thread::timed_join() with a minimal timeout. It will return false if the thread is still running.

    Sample code:

    thread_->timed_join(boost::posix_time::seconds(0));
    

提交回复
热议问题