开发者

boost thread, test if thread is ready to join

开发者 https://www.devze.com 2022-12-27 00:08 出处:网络
I would like to know if th开发者_StackOverflowere is a way to test whenever thread finished execution and is waiting for joining.My guess was the use time_join.

I would like to know if th开发者_StackOverflowere is a way to test whenever thread finished execution and is waiting for joining. My guess was the use time_join. is there explicit way to test it?


There's no API for that in boost::thread. I think the reason is that a thread can be detached and made not-joinable. Your best recourse is probably a wrapper and a flag.


timed_join with a duration of 0 can be seen as a try_join, so yes you can test if a thread has been finish. I think that there is already a feature request to add this try_join function to Boost.Thread.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号