-
Notifications
You must be signed in to change notification settings - Fork 652
Blog post alpha 2 #1134
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
Blog post alpha 2 #1134
Conversation
|
||
### Compatiblity layer for futures 0.1 | ||
|
||
We are currently working on an officially supported compatibility layer between `0.1` and `0.3`. This shim will make it possible to mix `0.1` futures with those from the 0.3 branch. The plan is to make it possible to use crates from the existing futures `0.1` ecosystem together with async functions and futures from the `0.3` crate. Additionally, this compatibility layer will also make it possible to gradually migrate exisiting applications and libraries to `0.3`. If you're curious, take a look the the [compatibility layer PR](https://github.com/rust-lang-nursery/futures-rs/pull/1119). |
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.
Maybe link to the WG-net issue as well?
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.
This looks fantastic! 💯
9bd7d01
to
db300d6
Compare
👍 compatibility layer stuff looks good, we can get some more details onto the tracking issue instead of cluttering the blog posts until we have some good examples ready. |
@Nemo157 Exactly what I had in mind. I think the blog should always only present things that work already. |
|
||
> Futures are polled until completion by tasks, a kind of lightweight "thread". A *task executor* is responsible for the creation of these tasks and the coordination of their execution on real operating system threads. In particular, whenever a task signals that it can make further progress via a wake-up notification, it is the responsibility of the task executor to put the task into a queue to continue executing it, i.e. polling the future in it, later. | ||
|
||
The notable difference to before is that the term "task" no longer refers to the future that the task runs. Instead, from now on, the term "task" only refers to the concept of a "lightweight" thread, a kind of thread that doesn't directly correspond to a thread provided by the operating system. This concept is sometimes also referred to as "green thread" - We, however, do not use either these terms because they tend to cause confusion with real operating system threads. Instead, we call this concept a "task" and the thing that runs them "task executor" or often just "executor". |
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.
Nit: no parens needed around "lightweight" thread
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.
Those are quotes 😉 - I'll remove them
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.
something something "technically correct == the best kind of correct"
``` | ||
|
||
- The `?`-operator used on a `Poll<Result<T, E>>` value: | ||
- yields `Poll::Pending` from the expression if the value is not ready. |
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.
"yields" is confusing here-- maybe something like
"When ?
is used on a Poll<Result<T, E>>
or a Poll<Option<Result<T, E>>>
containing an Err
value, it will return early. If the expression does not contain an error, it will result in a Poll<T>
or Poll<Option<T>>
, respectively."
- returns `Poll::Ready(Err(err_value))` from the function if the value is ready and an error. | ||
- The `ready!` macro used on a `Poll<T>` value: | ||
- yields the value of type `T` from the expression if the value is ready. | ||
- returns `Poll::pending` from the function if the value is not ready. |
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.
Nit: capitalize "pending"
- yields the value of type `T` from the expression if the value is ready. | ||
- returns `Poll::pending` from the function if the value is not ready. | ||
|
||
Additionally `Try` was also implemented for `Poll<Option<Result<T, E>>>`, more details on that in the [pull request](https://github.com/rust-lang/rust/pull/52721). |
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.
Maybe say something like "so now ?
" can be used in manual implementations and uses of Future
s and Stream
s."
db300d6
to
57d74f6
Compare
``` | ||
|
||
- The `?`-operator used on a `Poll<Result<T, E>>` behaves like this: | ||
- If there is an error, it early returns `Poll::Ready(Err(err))` |
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.
s/"early returns"/"returns early with" or just "returns"
|
||
- The `?`-operator used on a `Poll<Result<T, E>>` behaves like this: | ||
- If there is an error, it early returns `Poll::Ready(Err(err))` | ||
- Otherwise, it gives back the `Poll<T>` value, i.e. either `Poll::Pending` or `Poll::Ready(val)` |
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.
s/i.e.//
- Otherwise, it gives back the `Poll<T>` value, i.e. either `Poll::Pending` or `Poll::Ready(val)` | ||
|
||
- The `ready!` macro used on a `Poll<T>` value behaves like this: | ||
- If the value not ready, it early returns `Poll::Pending` |
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.
s/"the value not ready"/"the value is pending"
s/'It early returns"/"it returns early with"
- If the value not ready, it early returns `Poll::Pending` | ||
- Otherwise, it gives back the value of type `T` | ||
|
||
Additionally `Try` was also implemented for `Poll<Option<Result<T, E>>>` to make the `?`-operator useful in `Stream::poll` method implentations as well: |
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.
s/as well//
57d74f6
to
1eb6c51
Compare
|
ae93e26
to
ee2cfc5
Compare
ee2cfc5
to
50ea6de
Compare
Do not merge.
Rendered
Comments are welcome!