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; };