Fix test case bug

Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
JCW
2025-09-18 23:48:31 +01:00
parent ab52fde56e
commit 34706ef0ac
2 changed files with 7 additions and 7 deletions

View File

@@ -87,6 +87,8 @@ class JobQueue_test : public beast::unit_test::suite
while (yieldCount == 0)
;
coro->join();
// Now re-post until the Coro says it is done.
int old = yieldCount;
while (coro->runnable())

View File

@@ -83,11 +83,9 @@ JobQueue::Coro::yield()
if (shouldStop())
return;
{
std::lock_guard stateLock{mutex_run_};
state_ = CoroState::Suspended;
cv_.notify_all();
}
state_ = CoroState::Suspended;
cv_.notify_all();
++jq_.nSuspend_;
jq_.m_suspendedCoros[this] = weak_from_this();
jq_.cv_.notify_all();
@@ -115,11 +113,11 @@ inline void
JobQueue::Coro::resume()
{
{
if (state_ != CoroState::Suspended)
auto suspended = CoroState::Suspended;
if (!state_.compare_exchange_strong(suspended, CoroState::Running))
{
return;
}
state_ = CoroState::Running;
cv_.notify_all();
}
{