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 Future and task system to the standard library #51263
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
src/liballoc/task.rs
Outdated
| /// be `poll`ed. This function is like `wake`, but can only be called from the | ||
| /// thread on which this `Wake` was created. | ||
| /// | ||
| /// Executors generally maintain a queue of "ready" tasks; `wake` should place |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wake_local
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I quite like the way the LocalWaker pieces have worked out.
src/liballoc/task.rs
Outdated
| /// is local to the current thread. The resulting `LocalWaker` will call | ||
| /// `wake.wake()` when awoken. | ||
| #[inline] | ||
| pub fn local_waker_from_nonlocal<W: Wake + 'static>(wake: Arc<W>) -> LocalWaker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be a From coercion? Or do you prefer to keep it explicit?
The fact that we can't add it as an inherent constructor is a shame. But we can iterate on this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LocalWaker isn't defined in liballoc, so we can't add a From<impl Wake + 'static> for LocalWaker here. In any case, I think it might be a bit too tricky for users to figure out that wake_local won't be called via the From impl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@bors: r+ |
|
|
Add Future and task system to the standard library This adds preliminary versions of the `std::future` and `std::task` modules in order to unblock development of async/await (#50547). These shouldn't be considered as final forms of these libraries-- design questions about the libraries should be left on rust-lang/rfcs#2418. Once that RFC (or a successor) is merged, these APIs will be adjusted as necessary. r? @aturon
|
|
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
|
TIL |
|
|
Add Future and task system to the standard library This adds preliminary versions of the `std::future` and `std::task` modules in order to unblock development of async/await (#50547). These shouldn't be considered as final forms of these libraries-- design questions about the libraries should be left on rust-lang/rfcs#2418. Once that RFC (or a successor) is merged, these APIs will be adjusted as necessary. r? @aturon
|
|
This adds preliminary versions of the
std::futureandstd::taskmodules in order to unblock development of async/await (#50547). These shouldn't be considered as final forms of these libraries-- design questions about the libraries should be left on rust-lang/rfcs#2418. Once that RFC (or a successor) is merged, these APIs will be adjusted as necessary.r? @aturon