#pragma once
#include <myapp/async/signal.h>
#include <memory>
#include <uvw.hpp>

namespace myapp::async {

class uv_signal final : public signal
{
public:
    explicit uv_signal(std::shared_ptr<uvw::SignalHandle>);
    ~uv_signal();

    uv_signal(uv_signal &&) noexcept = default;
    uv_signal& operator=(uv_signal &&) noexcept = default;

    uvw::SignalHandle& handle() noexcept;
    uvw::SignalHandle const& handle() const noexcept;

    void on(int signum, std::function<void(int signum)>) override;
    void once(int signum, std::function<void(int signum)>) override;
    void stop() override;

private:
    std::shared_ptr<uvw::SignalHandle> signal_;
};

} /* namespace myapp::async */
