Files
daggy/libdaggy/include/daggy/executors/task/ForkingTaskExecutor.hpp
2022-01-12 12:50:46 -04:00

42 lines
1.2 KiB
C++

#pragma once
#include <daggy/ThreadPool.hpp>
#include "TaskExecutor.hpp"
namespace daggy::executors::task {
namespace forking_executor {
void validateTaskParameters(const ConfigValues &job);
}
class ForkingTaskExecutor : public TaskExecutor
{
public:
using Command = std::vector<std::string>;
explicit ForkingTaskExecutor(size_t nThreads);
~ForkingTaskExecutor() override;
// Validates the job to ensure that all required values are set and are of
// the right type,
bool validateTaskParameters(const ConfigValues &job) override;
std::vector<ConfigValues> expandTaskParameters(
const ConfigValues &job, const ConfigValues &expansionValues) override;
// Runs the task
TaskFuture execute(DAGRunID runID, const std::string &taskName,
const Task &task) override;
bool stop(DAGRunID runID, const std::string &taskName) override;
std::string description() const override;
private:
ThreadPool tp_;
std::mutex taskControlsGuard_;
AttemptRecord runTask(const Task &task, std::atomic<bool> &running);
std::unordered_map<std::string, std::atomic<bool>> taskControls_;
};
} // namespace daggy::executors::task