feat(cpp-object-oriented-modular-refactoring): step 5 - solver-workflow-google-style
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#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_
|
||||
Reference in New Issue
Block a user