Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix waker behavior when invoked before a poll finishes #54

Merged
merged 1 commit into from
Sep 17, 2021

Commits on Sep 17, 2021

  1. Fix waker behavior when invoked before a poll finishes

    It's possible for a task's waker to be invoked in the middle of a call
    to that task's `poll` by the executor. We had accounted for that
    possibility if the task called *its own* waker, but that's not good
    enough: the waker can escape to other threads that can invoke it before
    `poll` finishes (e.g., if the task blocks to acquire a lock).
    
    This change fixes the waker behavior by clarifying the semantics of a
    call to `wake`: a task whose waker is invoked should not be blocked
    *when it next returns Pending to the executor*, and should be woken if
    that has already happened. To do this, we introduce a new `Sleeping`
    state for tasks, that has the same semantics as `Blocked` but that is
    recognized by waker invocations, which will only unblock a task in
    `Sleeping` state. This also removes the special case "woken by self"
    behavior -- being woken by *any* thread should be enough to trigger this
    sleep logic.
    jamesbornholt committed Sep 17, 2021
    Configuration menu
    Copy the full SHA
    06a74d0 View commit details
    Browse the repository at this point in the history