diff --git a/lib/task.cc b/lib/task.cc index 0c47d3f..00c1dcb 100644 --- a/lib/task.cc +++ b/lib/task.cc @@ -791,11 +791,13 @@ namespace crucible { void BarrierState::release() { + set tasks_local; unique_lock lock(m_mutex); - for (auto i : m_tasks) { + swap(tasks_local, m_tasks); + lock.unlock(); + for (const auto &i : tasks_local) { i.run(); } - m_tasks.clear(); } BarrierState::~BarrierState()