[英]How to suspend and resume function of C++11 std::thread without touching the function itself?
I can wrap the desired function within another and manage eg that it would start when a condition fulfilled, but an 'endless loop' should not be organized around it. 我可以将所需的函数包装在另一个函数中并进行管理,例如,该函数将在满足条件时启动,但是不应围绕它组织“无限循环”。 As far as I know
pthread
supports suspend/resume by condition variables combined with muteces: wait/signal. 据我所知,
pthread
支持通过条件变量与静默结合使用的挂起/恢复:等待/信号。
std::thread
will just run it's Callable argument to completion, and the only interaction available is to join
or detatch
. std::thread
只会将其Callable参数运行至完成,并且唯一可用的交互是join
或detatch
。 The closest that you can get to what you want is to interrogate the native_handle
and do platform dependant things to that. 您最接近所需的方法是询问
native_handle
并对此进行平台相关的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.