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

Support aborting a task remotely in a multithreaded runtime without panicking #3159

Merged
merged 2 commits into from
Dec 4, 2020

Conversation

udoprog
Copy link
Contributor

@udoprog udoprog commented Nov 20, 2020

We have an issue in #3157 where a call to JoinHandle::abort releases a task, causing a panic because the current implementation of release for a thread pool requires it to be called from within a worker context.

This change makes access of the thread-local context optional under release, by falling back to remotely marking a task as dropped. Behaving the same as if the core was stolen by another worker.

Needs a review by someone familiar with the scheduler, cause I'm not entirely sure I've grok:ed the internals well enough.

@udoprog udoprog changed the title Abort without panic Support aborting a task in a multithreaded runtime without panicking Nov 20, 2020
@udoprog udoprog changed the title Support aborting a task in a multithreaded runtime without panicking Support aborting a task remotely in a multithreaded runtime without panicking Nov 20, 2020
@Darksonn Darksonn added A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-runtime Module: tokio/runtime labels Nov 20, 2020
@udoprog udoprog force-pushed the abort-without-panic branch from 8a50232 to 3796df0 Compare November 20, 2020 19:10
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this and it seems sound to me 👍 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-runtime Module: tokio/runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants