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

Add owner id for tasks in OwnedTasks #3979

Merged
merged 11 commits into from
Jul 27, 2021
Merged

Add owner id for tasks in OwnedTasks #3979

merged 11 commits into from
Jul 27, 2021

Conversation

Darksonn
Copy link
Contributor

This change makes OwnedTasks::remove safe and guarantees that non-Send tasks are not polled on the wrong thread.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime labels Jul 21, 2021
@Darksonn Darksonn requested a review from hawkw July 21, 2021 14:34
// the runtime has fully shut down.
//
// The assert below is unrelated to this mutex.
drop(remote_queue);
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason to remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was never necessary to hold the mutex locked for this long in the first place. It was introduced in #3752.

for task in self.context.tasks.borrow_mut().queue.drain(..) {
task.shutdown();
drop(task);
Copy link
Member

Choose a reason for hiding this comment

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

This was changed a bunch of places. I don't see a drop impl added on the type? Why is this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The type in question is Notified, and it already has a destructor. I changed it because otherwise you need to go through assert_owner to call shutdown. The call to shutdown has been unnecessary since #3955, as the inject queue and similar can no longer hold newly spawned tasks.

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.

Left some notes inline. Looks good, mostly nits. I had one question re: changing task.shutdown() to a drop.

@Darksonn Darksonn merged commit f2a06bf into master Jul 27, 2021
@Darksonn Darksonn deleted the owned-tasks-id branch July 27, 2021 08:41
@Darksonn Darksonn mentioned this pull request Aug 12, 2021
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 M-runtime Module: tokio/runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants