原书出处
Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)
02 Chapter 2. Basic Async Rust 取消怎样影响业务结果
and ensure that those interactions are cancel-safe.
In our example, if the slow_task() is canceled due to the timeout, the task itself is simply stopped, and the timeout returns an error indicating the task didn’t complete in time. Since tokio::time::sleep is a cancel-safe operation, there’s no risk of resource leaks or inconsistent states. However, if the task involves more complex operations, such as network communication or file I/O, additional care might be
needed to ensure that the cancellation is
原书定位详情
来源:a19c7933-4eda-4176-aebd-30fe7e1ad292
正文位置:extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch02.html#id400
EPUB SHA-256:109ff0224da54833b0d49c82502e850845274913fe34a7168dcf36a9c075b4e0