简体   繁体   中英

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.

std::thread will just run it's Callable argument to completion, and the only interaction available is to join or detatch . The closest that you can get to what you want is to interrogate the native_handle and do platform dependant things to that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM