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

#include "ExecutableCommand.h"


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

    void Shutdown();

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

    void RemoveFinishedTasks();

private:
    struct Task {
        std::shared_ptr<ExecutableCommand> command;
        std::future<void> future;
    };

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


#endif //COMMANDEXECUTOR_H
