#ifndef ALSK_ALSK_IMPL_BONE_FARM_H #define ALSK_ALSK_IMPL_BONE_FARM_H #include #include #include #include #include #include "../boneimplbase.h" #include "../../skeleton/bone/farm.h" namespace alsk { /** * @brief Farm implementation for sequential execution */ template struct Impl, tag::Sequential, Executor, State>: BoneImplBase, tag::Sequential, Executor, State> { using This = Impl; using Task = Execute; typename This::Skeleton skeleton; typename This::Executor executor; typename This::StateRef state; constexpr Impl() = default; template constexpr Impl(S&& skeleton, Executor executor, State& state): skeleton{std::forward(skeleton)}, executor{executor}, state{state} {} constexpr void operator()(Args... args) { executor.template executeSequential( *this, skeleton.task, std::forward_as_tuple(args...), skeleton.n ); } }; /** * @brief Farm implementation for parallel execution */ template struct Impl, tag::Parallel, Executor, State>: BoneImplBase, tag::Parallel, Executor, State> { using This = Impl; using Task = Execute; typename This::Skeleton skeleton; typename This::Executor executor; typename This::StateRef state; constexpr Impl() = default; template constexpr Impl(S&& skeleton, Executor executor, State& state): skeleton{std::forward(skeleton)}, executor{executor}, state{state} {} constexpr void operator()(Args... args) { executor.template executeParallel( *this, skeleton.task, std::forward_as_tuple(args...), skeleton.n ); } }; } #endif