#pragma once
#include <thread>
#include "task.h"
#include "detail/worker_meta.h"
namespace co_context {
    class [[nodiscard]] io_context final {
    private:
        friend struct detail::worker_meta;
        using worker_meta = detail::worker_meta;
    private:
        std::thread host_thread;
        worker_meta worker;
        // should io_context stop
        bool will_stop = false;
        ctx_id_t id;
    public:
        explicit io_context() noexcept;
        void init();
        void deinit();
        void start();
        void run();
        void co_spawn(task<void>&& entrance) noexcept;

    public:
        void do_submission_part() noexcept;
        void do_completion_part() noexcept;
        void do_worker_part();
    };
} // namespace co_context