16#include "PollerFd.hpp"
65 using Callback = std::move_only_function<void ()>;
87 std::chrono::milliseconds
timeout() const noexcept;
Macro-based enum <-> string utilities for dfx.
#define DECLARE_ENUM_STRING_FUNCTIONS(E)
Declare the enum string API (and std::formatter) for enum type E.
Definition EnumString.hpp:327
Macros to implement the Private State (PIMPL-like) idiom with value semantics.
#define DFX_PRIVATE_STATE(Class, logger)
Declare a private implementation state for a class.
Definition PrivateState.hpp:52
#define DFX_PRIVATE_STATE_DECLARE_RULE_OF_5(Class)
Declare Rule-of-5 special member functions using the private state pattern.
Definition PrivateState.hpp:82
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Timer(Poller &poller, std::chrono::milliseconds timeout, Callback cb, Mode mode=Mode::SingleShot)
Constructs and attaches a timer to a poller.
bool isSingleShot() const noexcept
Convenience check for Mode::SingleShot.
std::move_only_function< void()> Callback
Callback invoked when the timer expires.
Definition Timer.hpp:65
void close() noexcept
Closes the underlying timer resources and detaches from the poller.
Mode
Timer firing mode.
Definition Timer.hpp:58
@ SingleShot
Fire once, then automatically become inactive.
Definition Timer.hpp:59
@ Repeating
Fire repeatedly at the configured interval until stopped.
Definition Timer.hpp:60
void stop()
Disarms the timer without releasing the underlying FD.
Timer()
Constructs a detached (inactive) timer.
std::chrono::milliseconds timeout() const noexcept
Returns the configured timeout/period.
Mode mode() const noexcept
Returns the current mode.
bool isActive() const noexcept
Returns whether the timer is currently armed. A timer is considered active when it is registered in a...
bool isRepeating() const noexcept
Convenience check for Mode::Repeating.
void attach(Poller &poller, std::chrono::milliseconds timeout, Callback cb, Mode mode=Mode::SingleShot)
Attaches the timer to a poller and configures it.
std::chrono::milliseconds remainingTime() const
Returns the remaining time before the next expiration. If the timer is inactive, the returned duratio...
void start()
Arms the timer using the currently configured timeout.
Definition SocketClient.hpp:23
Definition Message.hpp:21