rosa/inc/alsk/impl/bone/loop.h

42 lines
1.1 KiB
C
Raw Permalink Normal View History

2021-05-10 16:14:24 +00:00
#ifndef ALSK_ALSK_IMPL_BONE_LOOP_H
#define ALSK_ALSK_IMPL_BONE_LOOP_H
#include <tuple>
#include "../boneimplbase.h"
#include "../../skeleton/bone/loop.h"
namespace alsk {
/**
* @brief Loop implementation for any execution
*/
template<typename R, typename... Args, typename Task, typename Tag, typename Executor, typename State>
struct Impl<Loop<R(Args...), Task>, Tag, Executor, State>:
BoneImplBase<Loop<R(Args...), Task>, Tag, Executor, State>
{
using This = Impl;
using ETask = Execute<typename This::Skeleton::TaskLinks>;
typename This::Skeleton skeleton;
typename This::Executor executor;
typename This::StateRef state;
constexpr Impl() = default;
template<typename S, typename O>
constexpr Impl(S&& skeleton, O&& executor, State& state):
skeleton{std::forward<S>(skeleton)},
executor{std::forward<O>(executor)},
state{state}
{}
constexpr typename This::Return operator()(Args... args) {
for(unsigned int i = 0; i < skeleton.n; ++i)
executor.template execute<ETask>(*this, skeleton.task, std::forward_as_tuple(args...), std::tuple<>{});
}
};
}
#endif