WaitableEvent waiting very long

WaitableEvent, after running processes for a bit (20 - 30 seconds), seems to not respect the timing. This just started recently happening (I noticed a recent change in GitHub so tried it the previous way (notify outside the lock and its a little better, but still happens)). In the condition.wait_for if I set it to 10 milliseconds it sometimes takes 10 seconds to come back. My CPU usage is at zero at this point. As I am waiting for all the jobs in a ThreadPool to finish.
Something like this:

  while(tPool.getNumJobs() > 0){
        jobFinishedSignal.wait (10);

and in every job(std::function) at the end:

Any Ideas on this. It is happening in Xcode 12.5.1 running Big Sur on Intel. Note this code is working fine in Linux and had been working great in OS X for quite a while. Also note that if I hit pause in Xcode and then continue, it usually continues just fine.

When applications are running in the background on Big Sur they can be put into a power saving state called “App Nap” - this sounds like what is happening in your case (see GitHub - msorvig/qt-and-app-nap: Qt And App Nap).

We recently added a ScopedLowPowerModeDisabler which will disable this feature, can you try adding this to your application and see if it fixes the timing issues?

1 Like

That worked perfectly. Thank you.