fs: document cancellation behavior of tokio::fs (#8265)

This commit is contained in:
kai-xlr
2026-08-07 22:14:05 +08:00
committed by GitHub
parent a5b2d1ff69
commit 4f7b8d6239
+11 -3
View File
@@ -16,9 +16,17 @@
//! such as hangs during runtime shutdown. For special files, you should use a
//! dedicated type such as [`tokio::net::unix::pipe`] or [`AsyncFd`] instead.
//!
//! Currently, Tokio will always use [`spawn_blocking`] on all platforms, but it
//! may be changed to use asynchronous file system APIs such as io_uring in the
//! future.
//! Tokio currently uses [`spawn_blocking`] on all platforms, but also uses
//! io_uring for file operations on Linux when compiled with `tokio_unstable`.
//! Operations that cannot be cancelled with [`spawn_blocking`] may possibly
//! be cancelled with io_uring.
//!
//! # Cancellation
//!
//! Cancelling a future from this module will stop waiting for the result, but
//! the underlying blocking operation will continue to run on the thread pool.
//! For example, cancelling a [`write()`] future after it has been
//! polled will still result in the data being written to disk.
//!
//! # Usage
//!