Skip to content

Commit

Permalink
Fix ancient race condition in TaskGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
tunabrain committed Jul 19, 2016
1 parent 9e08668 commit b1284a4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/thread/TaskGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <exception>
#include <stdexcept>
#include <atomic>
#include <thread>
#include <mutex>

namespace Tungsten {
Expand All @@ -34,6 +35,7 @@ class TaskGroup
if (_finisher && !_abort)
_finisher();

std::unique_lock<std::mutex> lock(_waitMutex);
_done = true;
_waitCond.notify_all();
}
Expand Down Expand Up @@ -74,8 +76,10 @@ class TaskGroup

void abort()
{
std::unique_lock<std::mutex> lock(_waitMutex);
_abort = true;
_done = _done || _startedSubTasks == 0;
_waitCond.notify_all();
}

bool isAborting() const
Expand Down

0 comments on commit b1284a4

Please sign in to comment.