#ifndef TASKEXECUTOR_H
#define TASKEXECUTOR_H
#include <functional>
#include <future>
#include <mutex>
#include <queue>

#include "ExecutableTask.h"

enum TaskType {
    Export,
    Bot,
    Test,
    NotDefined
};

class TaskExecutor {
public:
    TaskExecutor(): stop(false) {
    }

    void Shutdown();

    void AddTask(std::shared_ptr<ExecutableTask> command);

    bool IsTaskTypeRunning(TaskTypeEnum taskType) const;

    void RemoveFinishedTasks();

private:
    struct Task {
        std::shared_ptr<ExecutableTask> task;
        std::future<void> future;
    };

    std::vector<Task> tasks;
    mutable std::mutex queueMutex;
    std::atomic<bool> stop;
};


#endif //TASKEXECUTOR_H
