9 virtual void wait()
override {
21 return makeShared<SequentialTaskHandle>();
48 const Size granularity,
54 for (
Size n = from; n < to; n += granularity) {
56 const Size n2 =
min(n1 + granularity, to);
57 this->
submit([n1, n2, &functor] { functor(n1, n2); });
#define SPH_ASSERT(x,...)
uint32_t Size
Integral type used to index arrays (by default).
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
Additional math routines (with more includes).
#define NAMESPACE_SPH_END
Wrapper of type value of which may or may not be present.
SequentialScheduler SEQUENTIAL
Global instance of the sequential scheduler.
Interface for executing tasks (potentially) asynchronously.
virtual void parallelFor(const Size from, const Size to, const Size granularity, const Function< void(Size n1, Size n2)> &functor)
Processes the given range concurrently.
virtual SharedPtr< ITask > submit(const Function< void()> &task)=0
Submits a task to be potentially executed asynchronously.
Handle used to control tasks submitted into the scheduler.
Dummy scheduler that simply executes the submitted tasks sequentially on calling thread.
virtual Size getRecommendedGranularity() const override
Returns a value of granularity that is expected to perform well with the current thread count.
virtual SharedPtr< ITask > submit(const Function< void()> &task) override
Submits a task to be potentially executed asynchronously.
virtual Size getThreadCnt() const override
Returns the number of threads used by this scheduler.
static SharedPtr< SequentialScheduler > getGlobalInstance()
virtual Optional< Size > getThreadIdx() const override
Returns the index of the calling thread.
virtual void wait() override
Waits till the task and all the child tasks are completed.
virtual bool completed() const override
Checks if the task already finished.