Quantum Resource Manager and Compiler Infrastructure (QRM&CI) 0.1.0
mqss::qrmci::PublicationThrottle Class Reference

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.

Detailed Description

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.

Member Typedef Documentation

◆ Clock

using mqss::qrmci::PublicationThrottle::Clock = std::chrono::steady_clock

Monotonic clock used for slot timing.

Definition at line 30 of file PublicationThrottle.h.

Constructor & Destructor Documentation

◆ PublicationThrottle()

mqss::qrmci::PublicationThrottle::PublicationThrottle ( Clock::duration interval = DefaultInterval)
inlineexplicit

Construct a throttle with the given interval.

Parameters
intervalMinimum spacing between two publish slots.

Definition at line 38 of file PublicationThrottle.h.

Member Function Documentation

◆ claim()

bool mqss::qrmci::PublicationThrottle::claim ( Clock::time_point now = Clock::now())
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.

Parameters
nowThe current time.
Returns
True if the caller should refresh and publish its status now.

Definition at line 50 of file PublicationThrottle.h.

◆ getInterval()

Clock::duration mqss::qrmci::PublicationThrottle::getInterval ( ) const
inlinenodiscardnoexcept

Get the throttle's configured interval.

Returns
The configured publish interval.

Definition at line 60 of file PublicationThrottle.h.

Member Data Documentation

◆ DefaultInterval

Clock::duration mqss::qrmci::PublicationThrottle::DefaultInterval = std::chrono::seconds(5)
staticconstexpr

Minimum spacing between two publish slots, absent an explicit interval.

Definition at line 34 of file PublicationThrottle.h.


The documentation for this class was generated from the following file: