17enum class ParentCascadeCancel { kOff, kOn };
20#include <dispenso/detail/task_set_impl.h>
24constexpr ssize_t kDefaultStealingMultiplier = 4;
48 ParentCascadeCancel registerForParentCancel,
49 ssize_t stealingLoadMultiplier = kDefaultStealingMultiplier)
50 : TaskSetBase(p, registerForParentCancel, stealingLoadMultiplier),
51 token_(makeToken(p.work_)) {}
54 TaskSet(ThreadPool& p, ssize_t stealingLoadMultiplier)
55 :
TaskSet(p, ParentCascadeCancel::kOff, stealingLoadMultiplier) {}
75 if (DISPENSO_EXPECT(
canceled(),
false)) {
78 if (outstandingTaskCount_.load(std::memory_order_relaxed) > taskSetLoadFactor_) {
81 pool_.schedule(token_, packageTask(std::forward<F>(f)));
98 pool_.schedule(token_, packageTask(std::forward<F>(f)), fq);
107 DISPENSO_DLL_ACCESS
bool wait();
123 DISPENSO_DLL_ACCESS
bool tryWait(
size_t maxToExecute);
131 TaskSetBase::cancel();
140 return TaskSetBase::canceled();
152 DISPENSO_DLL_ACCESS moodycamel::ProducerToken makeToken(
153 moodycamel::ConcurrentQueue<OnceFunction>& pool);
155 moodycamel::ProducerToken token_;
157 template <
typename Result>
158 friend class detail::FutureBase;
184 ParentCascadeCancel registerForParentCancel,
185 ssize_t stealingLoadMultiplier = kDefaultStealingMultiplier)
186 : TaskSetBase(pool, registerForParentCancel, stealingLoadMultiplier) {}
212 template <
typename F>
214 if (outstandingTaskCount_.load(std::memory_order_relaxed) > taskSetLoadFactor_ &&
215 DISPENSO_EXPECT(!
canceled(),
true)) {
217 }
else if (skipRecheck) {
220 pool_.schedule(packageTask(std::forward<F>(f)));
235 template <
typename F>
237 pool_.schedule(packageTask(std::forward<F>(f)), fq);
244 DISPENSO_DLL_ACCESS
bool wait();
259 DISPENSO_DLL_ACCESS
bool tryWait(
size_t maxToExecute);
268 TaskSetBase::cancel();
277 return TaskSetBase::canceled();
289 bool tryExecuteNext() {
290 return pool_.tryExecuteNext();
293 template <
typename Result>
294 friend class detail::FutureBase;
296 friend class detail::LimitGatedScheduler;
304DISPENSO_DLL_ACCESS TaskSetBase* parentTaskSet();
void schedule(F &&f, bool skipRecheck=false)
void schedule(F &&f, ForceQueuingTag fq)
DISPENSO_DLL_ACCESS bool tryWait(size_t maxToExecute)
ConcurrentTaskSet(ThreadPool &pool, ParentCascadeCancel registerForParentCancel, ssize_t stealingLoadMultiplier=kDefaultStealingMultiplier)
DISPENSO_DLL_ACCESS bool wait()
DISPENSO_DLL_ACCESS bool tryWait(size_t maxToExecute)
void schedule(F &&f, ForceQueuingTag fq)
TaskSet(ThreadPool &p, ParentCascadeCancel registerForParentCancel, ssize_t stealingLoadMultiplier=kDefaultStealingMultiplier)
DISPENSO_DLL_ACCESS bool wait()