Address PR comments

Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
JCW
2025-11-21 16:53:41 +00:00
parent 472bcf6b03
commit 976fd8229b
2 changed files with 7 additions and 5 deletions

View File

@@ -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();

View File

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