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

[WIP] async and .await chapter with listings updates #3908

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented Apr 29, 2024

Note: Work is actually happening on #3909 – this one includes everything that one includes and the listings rework—but that means GitHub has a very bad time trying to render the diff. I am maintaining this branch and PR so that I can keep the listings in reasonably good shape as we make changes to src as it stands today, so that when we finally go to merge this thing it is not an extra pile of work all at once.


As of the time of opening the PR, this is the earliest possible draft material. 😅

A quick note for folks watching the repo: the state of this is roughly: Ready for @carols10cents to leave comments, and we’ll invite others to do so as well over time, but please don’t comment-bomb us at this phase! 😂

We will primarily just be re-exporting this, though we may also have a
couple cases where we choose to implement something small around it.
1. Introduce an integration tests crate. Structure it the way people
   *should* for large crates (although this is not that) and document
   why, including linking to a relevant post.
2. Add a basic integration test that verifies the re-export works as it
   should. (This is not exactly rocket science, but we want to make sure
   these things don’t just stop working on accident.)

An open question that remains here: do we want some structure to the
crate beyond the top level re-exports? My inclination at this moment is:
no, because we don’t have any *motivation* for that, and naming things
is difficult. (We cannot do `trpl::async`, for example, because `async`
is a keyword!)
- 17.00: Introduction to the conceptual machinery. This is very nascent
  but has some decent bones.
- 17.01: Trying to get at the foundations for tasks, laziness, etc.;
  this is *especially* incomplete.
- 17.02: Just a paragraph I do not want to lose, which I think *will*
  be useful… eventually.
Add a fair bit more material about the `futures` executor and why we
might prefer to use something else. With that motivation in place, have
the readers add our `trpl` crate. (We can of course rename that crate,
but it does the job for now.) Use it to get the equivalent of
`#[tokio::main]` equivalent and incorporate it into an example.
@carols10cents
Copy link
Member

😬 GitHub is straight up not having a good time rendering the full diff with all the listing changes... so I'm opening a new PR without the listings moving for now 😱

@chriskrycho
Copy link
Contributor Author

😂 Good job, GitHub!

Re-exporting the macro does not work unless you have `tokio` as a direct
dependency, because its expansion is in terms of Tokio doc-hidden items.
Add some listings which I can actually run, with `TODO` paths in them
since I do not know what the numbers will be, since I have not actually
finished with §0 or §1 yet!
Also rename the files to match their actual titles now that I know them.
Or at least: know a good first pass for them.
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 4f2eac9 to 1b65a13 Compare May 16, 2024 15:14
- Introduce the relevant supporting features in `trpl`.
- Add a couple listings to show how things do or do not work.
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 1b65a13 to 519793d Compare May 16, 2024 20:06
- Incorporate a good discusion of the need to make sure that the `tx`
  in this example gets dropped.
- Add more listings which show borrowing vs. moving a `tx`, covering
  the full territory in that example.
- Add and test more re-exports in `trpl`.

I made a conscious choice here *not* to use `future::join_all()` because
that ends up getting into a discussion of `Pin`. I left a TODO item here
for now because I think it is probably worth getting into, and that
could be a good thing to transition to *after* this section.
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 519793d to 1042508 Compare May 17, 2024 21:19
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 1042508 to dce2f83 Compare May 22, 2024 19:23
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from dce2f83 to a9bc8f4 Compare May 22, 2024 19:32
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch 2 times, most recently from ba2e1ca to a5dd285 Compare May 22, 2024 21:53
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from a5dd285 to 6b17385 Compare May 23, 2024 14:09
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 6b17385 to 383a374 Compare May 24, 2024 17:22
I am not 100% sure we will keep these, but right now they feel useful for
helping see how `async` can help solve some of these problems.
Tasks to be done:

- [ ] Update all listing *output* to match what it should be for the
    version of Rust we are using at the time we actually merge this.
- [ ] (Re-)Update all references to listings to be correct.
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 383a374 to 48400ae Compare May 24, 2024 23:13
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.

None yet

2 participants