#pragma once #include #include #include #include #include #include namespace Void::Process { /// Converts process signals into synchronous, deterministic waits. /// Construct this before worker threads so the selected signals inherit a /// blocked mask. A watcher must be destroyed on the thread that created it. class SignalWatcher { public: /// An empty signal list watches SIGINT and SIGTERM. [[nodiscard]] static Void::Result::Result create(std::vector signals = {}); ~SignalWatcher(); SignalWatcher(SignalWatcher&&) noexcept; SignalWatcher& operator=(SignalWatcher&&) noexcept; SignalWatcher(const SignalWatcher&) = delete; SignalWatcher& operator=(const SignalWatcher&) = delete; /// Wait for a configured signal. A zero timeout performs a poll; /// milliseconds::max() waits indefinitely. [[nodiscard]] Void::Result::Result> wait(std::chrono::milliseconds timeout = std::chrono::milliseconds::max()); [[nodiscard]] Void::Result::Result> poll(); private: struct Impl; std::unique_ptr m_impl; explicit SignalWatcher(std::unique_ptr impl) noexcept; }; } // namespace Void::Process