diff --git a/src/util/scoped_timer.cpp b/src/util/scoped_timer.cpp index 44bf30f4c..33c6a2dc8 100644 --- a/src/util/scoped_timer.cpp +++ b/src/util/scoped_timer.cpp @@ -34,7 +34,7 @@ struct scoped_timer_state { std::timed_mutex m_mutex; event_handler * eh; unsigned ms; - int work; + std::atomic work; std::condition_variable_any cv; }; @@ -102,6 +102,8 @@ public: ~imp() { s->m_mutex.unlock(); + while (s->work == 1) + std::this_thread::yield(); } };