renonsz
renonsz

Reputation: 591

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 e.g. 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.

Upvotes: 0

Views: 434

Answers (1)

Caleth
Caleth

Reputation: 62694

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.

Upvotes: 1

Related Questions