Skip to content

Commit

Permalink
Update src/part-guide/adv-async-await.md
Browse files Browse the repository at this point in the history
Co-authored-by: Travis Cross <[email protected]>
  • Loading branch information
nrc and traviscross authored Nov 18, 2024
1 parent cf54956 commit 32499d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/part-guide/adv-async-await.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The first two are specific to Tokio, though most runtimes provide similar facili

From the perspective of writing async code (in async functions, blocks, futures, etc.), the code might stop executing at any `await` (including hidden ones in macros) and never start again. In order for your code to be correct (specifically to be *cancellation safe*), it must never leave any data in an inconsistent state at any await point.

An example of how this can go wrong is if an async function reads data into an internal buffer, then awaits the next datum. If reading the data is destructive (i.e., cannot be re-read from the original source) and the async function is cancelled, then the internal buffer will be dropped, and the data in it will be lost.
An example of how this can go wrong is if an async function reads data into an internal buffer, then awaits the next datum. If reading the data is destructive (i.e., cannot be re-read from the original source) and the async function is canceled, then the internal buffer will be dropped, and the data in it will be lost.

We'll be coming back to cancellation and cancellation safety a few times in this guide, and there is a whole [chapter]() on the topic in the reference section.

Expand Down

0 comments on commit 32499d9

Please sign in to comment.