Resetting sleeping time of a thread
问题 Suppose to have a thread like this void mythread() { int res; while(1) { { boost::lock_guard<boost::mutex> lock(mylock); res = do_my_stuff(); } boost::this_thread::sleep(boost::posix_time::seconds(5)); } } and that the thread is currently sleeping. If something happens outside of the thread, I'd like to be able to increase the sleep time. What is the best way to do it? 回答1: Using a condition_variable to signal changes to the deadline This has the benefit of supporting scenarios where the