+
+ /// Make sure this thread not progress faster than the main thread.
+ void waitForMainThread() {
+ std::unique_lock<std::mutex> LockGuard(WaitMainThreadMutex);
+ WaitMainThread.wait(LockGuard, [&] { return MainThreadReady; });
+ }
+
+ /// Set the readiness of the main thread.
+ void setMainThreadReadyState(bool Ready) {
+ std::unique_lock<std::mutex> LockGuard(WaitMainThreadMutex);
+ MainThreadReady = Ready;
+ WaitMainThread.notify_all();
+ }
+
+ std::condition_variable WaitMainThread;
+ std::mutex WaitMainThreadMutex;
+ bool MainThreadReady;
+