Like a good deal of other people, I too am currently working on a little wrapper class for boost::thread and facing the problem to write a simple sleep(int miliseconds) function that can be called from another thread. Just like boost::thread::sleep() used to do. Since that function is going to be discontinued soon, there are new options: boost::this_thread::sleep_for() and sleep_until(). But I don't see how I could manage to achieve the wanted behaviour with those. And I also couldn't find a solution yet, even though this seems to be an issue to lots of people.
So I have my ThreadWrapper class with a boost::thread working inside. What I want to do is this:
ThreadWrapper thread(func_foo);
Thread.sleep(100); //tells the underlying boost:thread of my Threadwrapper
//to sleep 100ms
Any suggestions? Thanks!
int main() { boost::thread mThread(func_foo); mThread.sleep(boost::chrono::milliseconds(50)); }How can I achieve this, if I'm not supposed to use sleep() anymore? The new options sleep_for() and sleep_until() only allow a thread to put itself to sleep, in my example these would be called in the func_foo function. - DenverCoder21