#pragma once
#include <myapp/modbus/poll.h>
#include <atomic>
#include <mutex>
#include <queue>

namespace myapp::modbus {

class poll_impl final
	: public poll
	, public std::enable_shared_from_this<poll_impl>
{
public:
    task_executor_t executor() override;
    void run() override;
    void abort() override;

private:
    bool next_task(task_t&);

private:
    std::atomic<bool> aborted_{false};
    std::mutex mutex_{};
    std::queue<task_t> tasks_{};
};

} /* namespace myapp::modbus */
