Claims at most one status-publication slot per configured interval. More...
Public Types | |
| using | Clock = std::chrono::steady_clock |
| Monotonic clock used for slot timing. | |
Public Member Functions | |
| PublicationThrottle (Clock::duration interval=DefaultInterval) | |
| Construct a throttle with the given interval. | |
| bool | claim (Clock::time_point now=Clock::now()) |
| Claim the next publication slot, if one is due. | |
| Clock::duration | getInterval () const noexcept |
| Get the throttle's configured interval. | |
Static Public Attributes | |
| static constexpr Clock::duration | DefaultInterval = std::chrono::seconds(5) |
| Minimum spacing between two publish slots, absent an explicit interval. | |
Claims at most one status-publication slot per configured interval.
Carries no relationship to backend liveness: a process that never publishes its own status, such as the distributed selector, has no use for one and constructs none. A device-owning process constructs one alongside its BackendRegistry and consults it before re-reading and publishing its device's status.
Definition at line 27 of file PublicationThrottle.h.
| using mqss::qrmci::PublicationThrottle::Clock = std::chrono::steady_clock |
Monotonic clock used for slot timing.
Definition at line 30 of file PublicationThrottle.h.
|
inlineexplicit |
Construct a throttle with the given interval.
| interval | Minimum spacing between two publish slots. |
Definition at line 38 of file PublicationThrottle.h.
|
inlinenodiscard |
Claim the next publication slot, if one is due.
Returns true at most once per publish interval and stamps the slot as taken, so a caller can guard both its device interrogation and its status publication with it and stop doing either once per turn of a work loop that spins far faster than the status can meaningfully change. The first call always succeeds.
| now | The current time. |
Definition at line 50 of file PublicationThrottle.h.
|
inlinenodiscardnoexcept |
Get the throttle's configured interval.
Definition at line 60 of file PublicationThrottle.h.
|
staticconstexpr |
Minimum spacing between two publish slots, absent an explicit interval.
Definition at line 34 of file PublicationThrottle.h.