Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin the shutdown process before releasing the last waiter.
Once we push the final result on the resume queue the waiting thread may immediately resume, and see a Fiber that appears to be alive but which will actually soon be dead. By moving one of the death conditions before the final push, we will at least ensure the Fiber appears dead. There is an opposite side effect here, in that now a Fiber may appear to be dead a brief moment before it returns its last value, but this can only be observed from a third thread, which could not atomically know that both the final value had returned and the Fiber had declared itself dead. Fixes #4838.