33 lines
791 B
C++
33 lines
791 B
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <functional>
|
|
|
|
namespace fesa {
|
|
|
|
// Executes independent index-addressed work without exposing the backend.
|
|
// Callers own output storage and must confine each invocation to its index.
|
|
class ParallelFor {
|
|
public:
|
|
virtual ~ParallelFor() = default;
|
|
virtual void execute(
|
|
std::size_t count,
|
|
const std::function<void(std::size_t)>& body) const = 0;
|
|
};
|
|
|
|
class SerialParallelFor final : public ParallelFor {
|
|
public:
|
|
void execute(
|
|
std::size_t count,
|
|
const std::function<void(std::size_t)>& body) const override;
|
|
};
|
|
|
|
class TbbParallelFor final : public ParallelFor {
|
|
public:
|
|
void execute(
|
|
std::size_t count,
|
|
const std::function<void(std::size_t)>& body) const override;
|
|
};
|
|
|
|
} // namespace fesa
|