Skip to content

Commit f5b6455

Browse files
committed
Add documentation for SyncIoBridge with examples and alternatives
1 parent f3edf64 commit f5b6455

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tokio-util/src/io/sync_bridge.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use tokio::io::{
1818
///
1919
/// ### Why It Matters:
2020
/// `SyncIoBridge` allows you to use synchronous I/O operations in an asynchronous context by blocking the current thread. However, this can be inefficient because:
21-
/// - **Blocking:** The use of `SyncIoBridge` may block a valuable async runtime thread, which could otherwise be used to handle more tasks concurrently.
22-
/// - **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.
23-
/// - **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.
21+
/// - Blocking: The use of `SyncIoBridge` may block a valuable async runtime thread, which could otherwise be used to handle more tasks concurrently.
22+
/// - 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.
23+
/// - 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.
2424
///
2525
/// Instead, consider reading the data into memory and then hashing it, or processing the data in chunks.
2626
///

0 commit comments

Comments
 (0)