Skip to content

Commit 927d378

Browse files
authored
Merge pull request Amanieu#35 from zerodefect/master
When signaling to a waiting task, do not signal under the hold of a l…
2 parents b78d0c2 + efeaeb8 commit 927d378

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/task_wait_event.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class task_wait_event {
5656
// Check if a specific event is ready
5757
bool try_wait(int event)
5858
{
59-
std::unique_lock<std::mutex> lock(m);
59+
std::lock_guard<std::mutex> lock(m);
6060
int result = event_mask & event;
6161
event_mask &= ~event;
6262
return result != 0;
@@ -65,8 +65,9 @@ class task_wait_event {
6565
// Signal an event and wake up a sleeping thread
6666
void signal(int event)
6767
{
68-
std::lock_guard<std::mutex> lock(m);
68+
std::unique_lock<std::mutex> lock(m);
6969
event_mask |= event;
70+
lock.unlock();
7071
c.notify_one();
7172
}
7273
};

0 commit comments

Comments
 (0)