From: Radoslaw Zarzynski Date: Tue, 6 Dec 2022 12:06:39 +0000 (+0000) Subject: crimson/common: bring green_get() to interruptor X-Git-Tag: v18.1.0~260^2~23 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=301b2c6b8afe1fe3771584aa15b3ebaabdff05aa;p=ceph.git crimson/common: bring green_get() to interruptor The rationale ============= Calling `get()` on an unavailable future can result in yielding the reactor, so -- from the interruptor's POV -- the interrupt condition must be handled exactly like it is done for `yield()`. Interruptor takes care about that but, at the moment, only for the interruptible futures; there is mechanism for plain `seastar::future`. This patch paves the way for handling them as well. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/common/interruptible_future.h b/src/crimson/common/interruptible_future.h index 6ae8689357be1..c0e2c346c88b3 100644 --- a/src/crimson/common/interruptible_future.h +++ b/src/crimson/common/interruptible_future.h @@ -1413,6 +1413,28 @@ public: return ret; } + template + static decltype(auto) green_get(FutureT&& fut) { + if (fut.available()) { + return fut.get(); + } else { + // destined to wait! + auto interruption_condition = interrupt_cond.interrupt_cond; + INTR_FUT_DEBUG( + "green_get() waiting, interrupt_cond: {},{}", + (void*)interrupt_cond.interrupt_cond.get(), + typeid(InterruptCond).name()); + interrupt_cond.reset(); + auto&& value = fut.get(); + interrupt_cond.set(interruption_condition); + INTR_FUT_DEBUG( + "green_get() got, interrupt_cond: {},{}", + (void*)interrupt_cond.interrupt_cond.get(), + typeid(InterruptCond).name()); + return std::move(value); + } + } + static void yield() { ceph_assert(interrupt_cond.interrupt_cond); auto interruption_condition = interrupt_cond.interrupt_cond;