gtopt::ResourceGovernor::Ticket class

RAII admission ticket. Truthy when the task may run now. For a GPU task it also carries the assigned device; its destructor returns the token. Move-only.

Constructors, destructors, conversion operators

operator bool() const explicit noexcept
True when the task was admitted (CPU always; GPU iff a token was free).
Ticket() defaulted noexcept
empty / not-admitted
Ticket(const Ticket&) deleted
Ticket(Ticket&& other) noexcept
~Ticket()

Public functions

auto device() const -> std::optional<int> noexcept
Assigned GPU device (nullopt for CPU tasks / not admitted).
auto operator=(const Ticket&) -> Ticket& deleted
auto operator=(Ticket&& other) -> Ticket& noexcept