Skip to content

Introduce an alternative day-4-afternoon: async #492

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

Closed
wants to merge 2 commits into from

Conversation

djmitche
Copy link
Collaborator

@djmitche djmitche commented Mar 9, 2023

Fixes #181.

@djmitche djmitche requested a review from rbehjati March 9, 2023 22:51
@djmitche
Copy link
Collaborator Author

djmitche commented Mar 9, 2023

Note that this depends on #487. Once that lands, I'll rebase and the diff will contain only the async bits.

@djmitche
Copy link
Collaborator Author

rebase'd

@rbehjati do you want to write some of these chapters? I think you can push to this PR, or I could rebase this PR to point to an upstream branch and we could make a few PRs against that branch.

src/async.md Outdated
executing each task until it would block, then switching to another task that is
ready to make progress. The model scales to higher concurrency than threads
because the per-task overhead is typically very low and operating systems
provide means of efficiently selecting tasks that can make progress.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: It sounds like there is inherent OS support for async/await. Perhaps reword to something like "the async/await implementation relies on OS primitive to efficiently select the next tasks to run".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I addressed this, but I'm happy for more editing :)

At a high level, async Rust code looks very much like "normal" sequential code:

```rust,editable
use tokio::time;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to skip using tokio in this first example, and use futures and block_on?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

futures does not provide any time-based waking functionality. The only functionality in futures that would be non-trivial would be to send data over a channel, but I want to keep this example simple and parallel to the threads example.

Using futures for one of the later examples is a good idea, though.

@rbehjati
Copy link
Collaborator

rebase'd

@rbehjati do you want to write some of these chapters? I think you can push to this PR, or I could rebase this PR to point to an upstream branch and we could make a few PRs against that branch.

Sure. I can help. Most likely will have time to work on it in late March.

@rbehjati
Copy link
Collaborator

Also, I think it should be possible to add the content gradually (in separate PRs) and only add a link to it in src/SUMMARY.md when we are happy with the content.

@djmitche
Copy link
Collaborator Author

Also, I think it should be possible to add the content gradually (in separate PRs) and only add a link to it in src/SUMMARY.md when we are happy with the content.

I think this won't work, or at least would be confusing; this PR itself is getting errors because SUMMARY is incorrect.

Instead, I'll push to an issue181 branch on the upstream repo, and we can both make PRs against that.

@djmitche djmitche closed this Mar 10, 2023
@djmitche djmitche mentioned this pull request Mar 10, 2023
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.

Write chapter about async Rust
2 participants