Skip to content

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

Merged
merged 1 commit into from
Jul 30, 2018
Merged

Conversation

MajorBreakfast
Copy link
Contributor

@MajorBreakfast MajorBreakfast commented Jul 27, 2018

Do not merge.

Rendered

Comments are welcome!

@MajorBreakfast
Copy link
Contributor Author

MajorBreakfast commented Jul 27, 2018

@cramertj I tried to give an overview over what Try does for Poll. Can you look it over?
@tinaun @Nemo157 @aturon Is everything I say about the compatibility layer right?


### 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).
Copy link
Member

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?

Copy link
Member

@aturon aturon left a comment

Choose a reason for hiding this comment

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

This looks fantastic! 💯

@MajorBreakfast MajorBreakfast force-pushed the blog-alpha-2 branch 9 times, most recently from 9bd7d01 to db300d6 Compare July 27, 2018 15:00
@Nemo157
Copy link
Member

Nemo157 commented Jul 27, 2018

👍 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.

@MajorBreakfast
Copy link
Contributor Author

@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".
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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).
Copy link
Member

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 Futures and Streams."

```

- The `?`-operator used on a `Poll<Result<T, E>>` behaves like this:
- If there is an error, it early returns `Poll::Ready(Err(err))`
Copy link
Member

@cramertj cramertj Jul 27, 2018

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)`
Copy link
Member

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`
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

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

s/as well//

@cramertj
Copy link
Member

:shipit:

@MajorBreakfast MajorBreakfast force-pushed the blog-alpha-2 branch 3 times, most recently from ae93e26 to ee2cfc5 Compare July 28, 2018 11:15
@MajorBreakfast MajorBreakfast merged commit ae99a3a into rust-lang:gh-pages Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants