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

at_coroutine_exit can probably break scheduler affinity #535

Open
ispeters opened this issue May 31, 2023 · 0 comments
Open

at_coroutine_exit can probably break scheduler affinity #535

ispeters opened this issue May 31, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ispeters
Copy link
Contributor

I can't know without writing a unit test, but I'm pretty certain this breaks Scheduler affinity:

template <typename Scheduler>
task<void> foo(Scheduler someOtherScheduler) {
  co_await at_coroutine_exit([=]() noexcept {
    return schedule(someOtherScheduler);
  });
}

There's no infrastructure in the implementation of at_coroutine_exit to prevent the above from breaking the affinity invariant and no tests confirming that it doesn't break the invariant so it's almost certainly broken.

Note: the magic behaviour of co_await schedule(s); in a coroutine maintains the affinity invariant by using at_coroutine_exit to reschedule onto the correct Scheduler so fixing this will require some careful thought.

@ispeters ispeters added the bug Something isn't working label May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant