I see SetThreadExecutionState will prevent computer to sleep.
With boost::thread, how will I apply this to my software? With disable_interruption?
I see SetThreadExecutionState will prevent computer to sleep.
With boost::thread, how will I apply this to my software? With disable_interruption?
That's an operation system specific function, and completely unrelated to threading.
It's related to power management.
You could run /a/ background thread that does this in a loop, though:
void background_thread() {
while (true) {
boost::this_thread::sleep_for(boost::chrono::seconds(30));
::SetThreadExecutionState(...); // whatever you want to do
}
}
Ironically, you would want to use interuption points in order to gracefully terminate that thread (although you can use whatever synchronization mechanism you prefer)