Closed bitbugprime closed 3 years ago
Not sure about your code - at least if a fiber is waiting/blocked for some event it must be woken up.
Not sure about your code - at least if a fiber is waiting/blocked for some event it must be woken up.
How does the lambda loop ever exit? It looks like there is either a pending timer created by suspend_until which needs to be handled when it wakes up the main fiber suspended in branch A or, if all fibers other than the main fiber running the lambda loop have exited, in branch B run_one() will wait forever for work to execute, but there will never be work to execute because there are no fibers left to create that work.
I'm assuming the main fiber doesn't count for purposes of has_ready_fibers().
io_ctx_->stopped()
will return true
if io_ctx_->stop()
has been called.
io_ctx_->stopped()
will returntrue
ifio_ctx_->stop()
has been called.
So to get a clean shutdown the last running fiber needs to ensure all other fibers have exited, then call stop() just before it exits?
Take a look at the examples.
Assume I am the last running fiber for the thread executing io_context->run(), the same io_context that round_robin posted a handler-processing lambda to. What must that fiber do to ensure the "while (!ioctx->stopped()) {" loop exits when it exits, which should release the thread from run() since it's the last handler? I've tried to just exit the fiber for a clean shutdown but that merely seems to hang my program.