Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/DefaultTimer.cpp

Issue 29404610: Noissue - release mutex before call of notify_one (Closed)
Patch Set: Created April 6, 2017, 2:05 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/DefaultTimer.cpp
diff --git a/src/DefaultTimer.cpp b/src/DefaultTimer.cpp
index 597dec3effc0abc41fc9dc81dd473558287c799a..54fb39d9d8b57035371d3e5152a452991818435d 100644
--- a/src/DefaultTimer.cpp
+++ b/src/DefaultTimer.cpp
@@ -43,9 +43,11 @@ void DefaultTimer::SetTimer(const std::chrono::milliseconds& timeout, const Time
{
if (!timerCallback)
return;
- std::lock_guard<std::mutex> lock(mutex);
- TimerUnit timer = { std::chrono::steady_clock::now() + timeout, timerCallback };
- timers.push(timer);
+ {
+ std::lock_guard<std::mutex> lock(mutex);
+ TimerUnit timer = { std::chrono::steady_clock::now() + timeout, timerCallback };
+ timers.push(timer);
+ }
conditionVariable.notify_one();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld