void RunLoop() { ZAcqMtx acq(fMtx); double expires = Time::sSystem() + 10; for (;;) { if (fQueue.empty()) { ZThread::sSetName("SONT idle"); if (not fKeepRunning) { fCnd.Broadcast(); break; } else if (Time::sSystem() > expires) { break; } ++fIdleThreads; fCnd.WaitFor(fMtx, 5); --fIdleThreads; } else { ZThread::sSetName("SONT call"); ZRef<Callable<void()>> theCallable = fQueue.front(); fQueue.pop_front(); try { ZRelMtx acq(fMtx); theCallable->QCall(); } catch (...) {} } } --fActiveThreads; }