Fix edge case

Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
JCW
2025-09-25 14:47:05 +01:00
parent 622bb71cba
commit 52439ebb2d

View File

@@ -96,6 +96,16 @@ JobQueue::Coro::yield()
inline bool
JobQueue::Coro::post()
{
if (state_ == CoroState::Finished)
{
// The coroutine will run until it finishes if the JobQueue has stopped.
// In the case where make_shared<Coro>() succeeds and then the JobQueue
// stops before coro_ gets executed, post() will still be called and
// state_ will be Finished. We should return false and avoid XRPL_ASSERT
// as it's a valid edge case.
return false;
}
XRPL_ASSERT(
state_ == CoroState::Suspended,
"JobQueue::Coro::post: coroutine should be suspended!");