0

I see SetThreadExecutionState will prevent computer to sleep.

With boost::thread, how will I apply this to my software? With disable_interruption?

emrahustun
  • 31
  • 1
  • 5

1 Answers1

1

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)

sehe
  • 374,641
  • 47
  • 450
  • 633