From cd8edbce3f3acb1cbdbeb00cb98448a8895d469e Mon Sep 17 00:00:00 2001 From: Nathy-bajo Date: Wed, 4 Sep 2024 10:59:45 +0100 Subject: [PATCH] Add documentation for SyncIoBridge with examples and alternatives --- tokio-util/src/io/sync_bridge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tokio-util/src/io/sync_bridge.rs b/tokio-util/src/io/sync_bridge.rs index adc640436ab..c81fac1c6ad 100644 --- a/tokio-util/src/io/sync_bridge.rs +++ b/tokio-util/src/io/sync_bridge.rs @@ -18,9 +18,9 @@ use tokio::io::{ /// /// ### Why It Matters: /// `SyncIoBridge` allows you to use synchronous I/O operations in an asynchronous context by blocking the current thread. However, this can be inefficient because: -/// - Blocking: The use of `SyncIoBridge` may block a valuable async runtime thread, which could otherwise be used to handle more tasks concurrently. -/// - Thread Pool Saturation: If many threads are blocked using `SyncIoBridge`, it can exhaust the async runtime's thread pool, leading to increased latency and reduced throughput. -/// - Lack of Parallelism: By blocking on synchronous operations, you may miss out on the benefits of running tasks concurrently, especially in I/O-bound operations where async tasks could be interleaved. +/// Blocking: The use of `SyncIoBridge` may block a valuable async runtime thread, which could otherwise be used to handle more tasks concurrently. +/// Thread Pool Saturation: If many threads are blocked using `SyncIoBridge`, it can exhaust the async runtime's thread pool, leading to increased latency and reduced throughput. +/// Lack of Parallelism: By blocking on synchronous operations, you may miss out on the benefits of running tasks concurrently, especially in I/O-bound operations where async tasks could be interleaved. /// /// Instead, consider reading the data into memory and then hashing it, or processing the data in chunks. ///