From a70f96229df508385c339d62a5b6f46b1bf9dd07 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Tue, 30 Jan 2024 02:55:13 -0600 Subject: [PATCH] common: allow AsyncReserver requests with no callbacks As no callbacks are needed for request_reservation_or_fail(), the synchronous request API. Signed-off-by: Ronen Friedman --- src/common/AsyncReserver.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/AsyncReserver.h b/src/common/AsyncReserver.h index 32b558b308b..b98e54ef767 100644 --- a/src/common/AsyncReserver.h +++ b/src/common/AsyncReserver.h @@ -113,8 +113,10 @@ class AsyncReserver { if (it->second.empty()) { queues.erase(it); } - f->queue(p.grant); - p.grant = nullptr; + if (p.grant) { + f->queue(p.grant); + p.grant = nullptr; + } in_progress[p.item] = p; if (p.preempt) { preempt_by_prio.insert(std::make_pair(p.prio, p.item)); @@ -274,8 +276,7 @@ public: * active reservations. */ bool request_reservation_or_fail( - T item, ///< [in] reservation key - Context *on_reserved ///< [in] callback to be called on reservation + T item ///< [in] reservation key ) { std::lock_guard l(lock); @@ -288,7 +289,7 @@ public: } const unsigned prio = UINT_MAX; - Reservation r(item, prio, on_reserved, nullptr); + Reservation r(item, prio, nullptr, nullptr); queues[prio].push_back(r); queue_pointers.insert(std::make_pair( item, std::make_pair(prio, --(queues[prio]).end()))); -- 2.39.5