aboutsummaryrefslogtreecommitdiff
path: root/build2/scheduler.txx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/scheduler.txx')
-rw-r--r--build2/scheduler.txx10
1 files changed, 6 insertions, 4 deletions
diff --git a/build2/scheduler.txx b/build2/scheduler.txx
index c7e6ef2..dd98b4a 100644
--- a/build2/scheduler.txx
+++ b/build2/scheduler.txx
@@ -66,6 +66,12 @@ namespace build2
typename task::args_type (decay_copy (forward<A> (a))...)};
td->thunk = &task_thunk<F, A...>;
+
+ // Increment the task count. This has to be done under lock to prevent
+ // the task from decrementing the count before we had a chance to
+ // increment it.
+ //
+ task_count.fetch_add (1, std::memory_order_release);
}
else
{
@@ -98,10 +104,6 @@ namespace build2
}
}
- // Increment the task count.
- //
- task_count.fetch_add (1, std::memory_order_release);
-
// If there is a spare active thread, wake up (or create) the helper
// (unless someone already snatched it).
//