diff options
-rw-r--r-- | build2/scheduler | 9 | ||||
-rw-r--r-- | build2/scheduler.txx | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/build2/scheduler b/build2/scheduler index 16cc217..7447021 100644 --- a/build2/scheduler +++ b/build2/scheduler @@ -67,17 +67,20 @@ namespace build2 // subtlety can become important when passing shared locks; you would // only want it to be copied if the task is queued). // + // Return true if the task was queued and false if it was executed + // synchronously. + // // If the scheduler is shutdown, throw system_error(ECANCELED). // template <typename F, typename... A> - void + bool async (size_t start_count, atomic_count& task_count, F&&, A&&...); template <typename F, typename... A> - void + bool async (atomic_count& task_count, F&& f, A&&... a) { - async (0, task_count, forward<F> (f), forward<A> (a)...); + return async (0, task_count, forward<F> (f), forward<A> (a)...); } // Wait until the task count reaches the start count. If the scheduler is diff --git a/build2/scheduler.txx b/build2/scheduler.txx index 01408ca..d5e9afa 100644 --- a/build2/scheduler.txx +++ b/build2/scheduler.txx @@ -7,7 +7,7 @@ namespace build2 { template <typename F, typename... A> - void scheduler:: + bool scheduler:: async (size_t start_count, atomic_count& task_count, F&& f, A&&... a) { using task = task_type<F, A...>; @@ -56,7 +56,7 @@ namespace build2 if (td == nullptr) { forward<F> (f) (forward<A> (a)...); - return; + return false; } // Increment the task count. @@ -70,6 +70,8 @@ namespace build2 // if (active_ < max_active_) activate_helper (l); + + return true; } template <typename F, typename... A> |