EM 发帖数: 715 | 1 怎么知道一个thread已经complete了?
thread.joinable(), future<>.valid, future<>.wait_for(), future<>.wait_util()
好像都不行嘛
请C++大侠们指教 |
t****t 发帖数: 6806 | 2 i don't think you can check whether a thread is completed. So you have to do
it yourself: set a shared flag at the end of thread.
()
【在 EM 的大作中提到】 : 怎么知道一个thread已经complete了? : thread.joinable(), future<>.valid, future<>.wait_for(), future<>.wait_util() : 好像都不行嘛 : 请C++大侠们指教
|
EM 发帖数: 715 | 3 就是很好奇为什么native language的future template class不保留is_ready(),
anthony williams的justthread里面的future就有这个函数,难道没有通过?
do
【在 t****t 的大作中提到】 : i don't think you can check whether a thread is completed. So you have to do : it yourself: set a shared flag at the end of thread. : : ()
|
t****t 发帖数: 6806 | 4 POSIX thread can not check whether a thread is completed.
【在 EM 的大作中提到】 : 就是很好奇为什么native language的future template class不保留is_ready(), : anthony williams的justthread里面的future就有这个函数,难道没有通过? : : do
|
EM 发帖数: 715 | 5 native thread阿,不是pthread...
【在 t****t 的大作中提到】 : POSIX thread can not check whether a thread is completed.
|
r*********r 发帖数: 3195 | 6 c++ 有什么native threads?
libstdc++ 多半是用 pthread 写的。 |
h**********c 发帖数: 4120 | 7 A thread is complete, you will know it.
But there is no reliable way, as far as I know, to check a thread is
complete.
Let's say a process, you must set the read or write lock for the process
table,you read a state, when you release the lock, another state. |
t****t 发帖数: 6806 | 8 问题是, C++不可能管你的native thread. 能写进C++标准的一定是大家都有的.
【在 EM 的大作中提到】 : native thread阿,不是pthread...
|
t****t 发帖数: 6806 | 9 应该是什么平台就有什么实现吧. STL里都是wrapper而已.
【在 r*********r 的大作中提到】 : c++ 有什么native threads? : libstdc++ 多半是用 pthread 写的。
|
c*******y 发帖数: 1630 | 10 thread::timed_join(0) but possible race condition.
It will return false if the thread is still running.
()
【在 EM 的大作中提到】 : 怎么知道一个thread已经complete了? : thread.joinable(), future<>.valid, future<>.wait_for(), future<>.wait_util() : 好像都不行嘛 : 请C++大侠们指教
|