On 28/11/2017 18:09, Jeff Cody wrote: >> Yes, terminating a scheduled coroutine is a bug; same for scheduling a >> terminated coroutine, both orders are wrong. However, "unscheduling" is >> not the solution; you would just be papering over the issue. > > Maybe we should at least add an abort on coroutine termination if there are > still outstanding schedules, as that is preferable to operating in the > weeds.
Sure, why not. I'm all for adding more assertions (not less :)). >> aio_co_schedule() on a running coroutine can only happen when the >> coroutine is going to yield soon. >> > That is a bit vague. What is "soon", and how does an external caller know > if a coroutine is going to yield in this timeframe? Soon really means "eventually"; basically if you do f(); qemu_coroutine_yield(); then f() can call aio_co_wake() or aio_co_schedule() and knows that it will be entirely thread-safe. However, remember that only one aio_co_schedule() can be pending at a single time; so if you have f(); g(); qemu_coroutine_yield(); either f() or g() can wake you up but not both. Thanks, Paolo