Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion gtsam/base/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Scheduler {

// Notify waiters only when work transitions to "done".
if (activeTasks_.fetch_sub(1, std::memory_order_release) == 1) {
std::lock_guard<std::mutex> lock(waitMutex_);
condition_.notify_all();
}
}
Expand Down Expand Up @@ -183,7 +184,10 @@ class Scheduler {

queuedTasks_.fetch_add(1, std::memory_order_release);
activeTasks_.fetch_add(1, std::memory_order_release);
condition_.notify_one();
{
std::lock_guard<std::mutex> lock(waitMutex_);
condition_.notify_one();
}
return true;
}

Expand All @@ -201,6 +205,7 @@ class Scheduler {
} catch (...) { /* ignore */
}
if (activeTasks_.fetch_sub(1, std::memory_order_release) == 1) {
std::lock_guard<std::mutex> lock(waitMutex_);
condition_.notify_all();
}
}
Expand Down
Loading