From 976fd8229be7a4260b9d4915f74608392019423a Mon Sep 17 00:00:00 2001 From: JCW Date: Fri, 21 Nov 2025 16:53:41 +0000 Subject: [PATCH] Address PR comments Signed-off-by: JCW --- src/xrpld/core/Coro.ipp | 4 ++-- src/xrpld/core/JobQueue.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/xrpld/core/Coro.ipp b/src/xrpld/core/Coro.ipp index 67844ec672..de2c8e1d98 100644 --- a/src/xrpld/core/Coro.ipp +++ b/src/xrpld/core/Coro.ipp @@ -71,13 +71,13 @@ inline JobQueue::Coro::~Coro() "ripple::JobQueue::Coro::~Coro : is finished"); } -inline void +inline bool JobQueue::Coro::yield() { { std::lock_guard lock(jq_.m_mutex); if (shouldStop()) - return; + return false; state_ = CoroState::Suspended; cv_.notify_all(); diff --git a/src/xrpld/core/JobQueue.h b/src/xrpld/core/JobQueue.h index 8de34b594a..c324ef5b1e 100644 --- a/src/xrpld/core/JobQueue.h +++ b/src/xrpld/core/JobQueue.h @@ -99,9 +99,11 @@ public: Note: The associated Job function returns. Undefined behavior if called consecutively without a corresponding - post. + post. + It may not suspend at all if the JobQueue is stopping, and returns + false in such a case. */ - void + bool yield(); /** Schedule coroutine execution. @@ -147,7 +149,7 @@ public: join(); /** Returns true if the coroutine should stop executing */ - bool + [[nodiscard]] bool shouldStop() const; };