File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class LoopingThread {
23
23
std::timed_mutex waitMutex_;
24
24
std::unique_lock<std::timed_mutex> waitLock_;
25
25
std::mutex pauseMutex_;
26
+ std::unique_lock<std::mutex> pauseLock_;
26
27
std::mutex resumeMutex_;
27
28
std::unique_lock<std::mutex> resumeLock_;
28
29
bool exiting_ = false ;
@@ -34,7 +35,6 @@ class LoopingThread {
34
35
inline void work ()
35
36
{
36
37
std::chrono::steady_clock::time_point awakenAt = std::chrono::steady_clock::now ();
37
- std::unique_lock<std::mutex> pauseLock (pauseMutex_);
38
38
while (true ) {
39
39
bool interrupted = false ;
40
40
{
@@ -53,9 +53,9 @@ class LoopingThread {
53
53
54
54
if (interrupted) {
55
55
if (exiting_) break ;
56
- pauseLock .unlock ();
56
+ pauseLock_ .unlock ();
57
57
std::unique_lock<std::mutex> lock (resumeMutex_);
58
- pauseLock .lock ();
58
+ pauseLock_ .lock ();
59
59
} else {
60
60
try {
61
61
routine_ ();
@@ -92,6 +92,7 @@ class LoopingThread {
92
92
period_(period),
93
93
routine_(routine),
94
94
waitLock_(waitMutex_, std::defer_lock),
95
+ pauseLock_(pauseMutex_),
95
96
resumeLock_(resumeMutex_),
96
97
paused_(true ),
97
98
resetTimeOnPause_(false ),
@@ -114,6 +115,7 @@ class LoopingThread {
114
115
else
115
116
waitLock_.unlock ();
116
117
worker_.join ();
118
+ pauseLock_.unlock ();
117
119
}
118
120
}
119
121
You can’t perform that action at this time.
0 commit comments