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

the documentation for the Future trait specifies invariants that are not always true #125050

Open
lolbinarycat opened this issue May 12, 2024 · 0 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link

Location

https://doc.rust-lang.org/std/future/trait.Future.html

Summary

A future represents an asynchronous computation obtained by use of async.

this is not always true, a future represents a value that can be joined into an async function using await, however futures can be returned by non-async functions, such as tokio::task::spawn

Runtime characteristics

Futures alone are inert; they must be actively polled to make progress, meaning that each time the current task is woken up, it should actively re-poll pending futures that it still has an interest in.

once again, this is true for futures created by calling async functions, but may not be true for all types that implement the Future trait, such as tokio::task::JoinHandle.

the distinction between futures that are and are not inert is important, an array of task::JoinHandle is useful for performing several operations concurrently, however an array of futures created by calling async functions will not result in concurrent execution if they are awaited sequentially.

@lolbinarycat lolbinarycat added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label May 12, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 12, 2024
@jieyouxu jieyouxu added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 13, 2024
@fmease fmease changed the title the documentation for the Future trait specifies invarients that are not always true the documentation for the Future trait specifies invariants that are not always true May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants