26namespace mqss::qrmci {
55 using Clock = std::chrono::steady_clock;
84 Clock::time_point now = Clock::now());
90 std::size_t
expire(Clock::time_point now = Clock::now());
104 [[nodiscard]]
bool contains(std::string_view backendName)
const;
108 [[nodiscard]] std::size_t
size() const noexcept {
return entries.size(); }
112 [[nodiscard]]
bool empty() const noexcept {
return entries.empty(); }
117 return entryTimeToLive;
126 for (
const auto &[backendName, entry] : entries) {
127 std::invoke(fn, backendName, entry.backend);
134 Clock::time_point lastRefreshed;
140 std::map<std::string, Entry, std::less<>> entries;
BackendSelectionPolicy
Named rule deciding which backend wins when several of them could run the same task.
@ LowestName
The compatible backend whose name sorts first.
@ SmallestSufficient
The compatible backend with the fewest qubits (best fit, leaving the larger devices free for larger c...
One backend's capabilities as the QRM&CI pipeline sees them, read either from a live device or from a...
BackendRegistry(Clock::duration timeToLive)
Construct a registry with an explicit time-to-live.
std::chrono::steady_clock Clock
Monotonic clock used for entry freshness.
std::size_t size() const noexcept
Get the number of registered backends.
BackendRegistry()=default
Construct a registry with the default time-to-live.
std::size_t expire(Clock::time_point now=Clock::now())
Drop every entry last refreshed longer ago than the registry's time-to-live.
bool insertOrRefresh(BackendWrapper backend, Clock::time_point now=Clock::now())
Insert a backend, or refresh the entry already registered under the same name, and stamp it as last h...
bool contains(std::string_view backendName) const
Check whether a backend is registered under a given name.
bool empty() const noexcept
Check whether the registry holds no backends.
const BackendWrapper * find(std::string_view backendName) const
Look up a backend by name.
Clock::duration getTimeToLive() const noexcept
Get the registry's entry time-to-live.
void forEachBackend(Fn &&fn) const
Apply a function to every registered backend, in ascending backend-name order.
static constexpr Clock::duration DefaultTimeToLive
How long an entry stays usable after it was last refreshed.
A snapshot of one backend's capabilities: name, qubit count, status, supported instructions,...