1 | #![cfg (feature = "full" )] |
2 | use tokio::io::{AsyncBufReadExt, AsyncReadExt}; |
3 | |
4 | #[tokio::test ] |
5 | async fn empty_read_is_cooperative() { |
6 | tokio::select! { |
7 | biased; |
8 | |
9 | _ = async { |
10 | loop { |
11 | let mut buf = [0u8; 4096]; |
12 | let _ = tokio::io::empty().read(&mut buf).await; |
13 | } |
14 | } => {}, |
15 | _ = tokio::task::yield_now() => {} |
16 | } |
17 | } |
18 | |
19 | #[tokio::test ] |
20 | async fn empty_buf_reads_are_cooperative() { |
21 | tokio::select! { |
22 | biased; |
23 | |
24 | _ = async { |
25 | loop { |
26 | let mut buf = String::new(); |
27 | let _ = tokio::io::empty().read_line(&mut buf).await; |
28 | } |
29 | } => {}, |
30 | _ = tokio::task::yield_now() => {} |
31 | } |
32 | } |
33 | |