Files
FESADev/include/fesa/assembly/parallel_for.h
T

40 lines
1.1 KiB
C++

#ifndef FESA_ASSEMBLY_PARALLEL_FOR_H_
#define FESA_ASSEMBLY_PARALLEL_FOR_H_
#include <cstddef>
#include <functional>
namespace fesa {
/// @brief Executes independent index-addressed work behind a backend boundary.
/// @note Callers own output storage and each invocation may write only its
/// index-owned slot.
class ParallelFor {
public:
virtual ~ParallelFor() = default;
/// @brief Invokes body once for every index in [0, count).
virtual void Execute(std::size_t count,
const std::function<void(std::size_t)>& body) const = 0;
};
/// @brief Executes index-addressed work serially.
class SerialParallelFor final : public ParallelFor {
public:
/// @copydoc ParallelFor::Execute
void Execute(std::size_t count,
const std::function<void(std::size_t)>& body) const override;
};
/// @brief Executes index-addressed work through oneTBB.
class TbbParallelFor final : public ParallelFor {
public:
/// @copydoc ParallelFor::Execute
void Execute(std::size_t count,
const std::function<void(std::size_t)>& body) const override;
};
} // namespace fesa
#endif // FESA_ASSEMBLY_PARALLEL_FOR_H_