Skip to content

Commit 362aaac

Browse files
Updated Signal class to allow notify_all()
1 parent 6fdc0c1 commit 362aaac

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Common/interface/LockHelper.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class Signal
137137
Signal() {}
138138

139139
// http://en.cppreference.com/w/cpp/thread/condition_variable
140-
void Trigger()
140+
void Trigger(bool bNotifyAll = false)
141141
{
142142
// The thread that intends to modify the variable has to
143143
// * acquire a std::mutex (typically via std::lock_guard)
@@ -150,7 +150,10 @@ class Signal
150150
}
151151
// Unlocking is done before notifying, to avoid waking up the waiting
152152
// thread only to block again (see notify_one for details)
153-
m_CondVar.notify_one();
153+
if(bNotifyAll)
154+
m_CondVar.notify_all();
155+
else
156+
m_CondVar.notify_one();
154157
}
155158

156159
void Wait()
@@ -182,7 +185,7 @@ class Signal
182185
std::mutex m_Mutex;
183186
std::condition_variable m_CondVar;
184187
volatile bool m_bIsTriggered = false;
185-
188+
186189
Signal(const Signal&) = delete;
187190
Signal& operator = (const Signal&) = delete;
188191
};

0 commit comments

Comments
 (0)