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 guarantee about when a spawned task may be polled #5816

Merged
merged 1 commit into from Jun 27, 2023

Conversation

Diggsey
Copy link
Contributor

@Diggsey Diggsey commented Jun 25, 2023

Motivation

This guarantee is widely relied upon for correctness, but is not explicitly mentioned in the documentation.

Solution

No code changes.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task labels Jun 26, 2023
Comment on lines 18 to 19
/// If the task is executed on the current thread it will not begin executing
/// until the current task yields to the executor. In other words, `spawn`
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be interpreted as "but the multi-threaded runtime might do that!".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to reword it if you have an alternate suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about:

It is guaranteed that spawn will not synchronously poll the task being spawned. This means that calling spawn while holding a lock does not pose a risk of deadlocking with the spawned task.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated 👍

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thanks.

@Darksonn Darksonn merged commit 657fd88 into tokio-rs:master Jun 27, 2023
55 checks passed
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-task Module: tokio/task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants