Skip to content

Commit

Permalink
scoped_timer: wait for timer thread before main thread continues (#4803)
Browse files Browse the repository at this point in the history
  • Loading branch information
regehr authored Nov 19, 2020
1 parent e16acd0 commit 0fa88ef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util/scoped_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct scoped_timer_state {
std::timed_mutex m_mutex;
event_handler * eh;
unsigned ms;
int work;
std::atomic<int> work;
std::condition_variable_any cv;
};

Expand Down Expand Up @@ -102,6 +102,8 @@ struct scoped_timer::imp {

~imp() {
s->m_mutex.unlock();
while (s->work == 1)
std::this_thread::yield();
}
};

Expand Down

0 comments on commit 0fa88ef

Please # to comment.