#include <cstdint>
#include <span>
#include "task_info.h"
namespace co_context::detail {
    class lazy_awaiter {
    protected:
        task_info io_info;
    public:
        lazy_awaiter() noexcept {
            this_thread.worker->forward_lazy();
        }
        [[nodiscard]]
        int32_t result() const noexcept {
            return io_info.result;
        }
        static constexpr bool await_ready() noexcept { return false; }
        int32_t await_resume() const noexcept { 
            return result(); 
        }
        void await_suspend(std::coroutine_handle<> current) noexcept {
            io_info.handle = current;
        }
    };

    struct lazy_write : lazy_awaiter {
        inline
        lazy_write(int fd, std::span<const char> buf, uint64_t offset) noexcept {}
    };
}