File: io_repeat.rs

package info (click to toggle)
rust-tokio 1.48.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,444 kB
  • sloc: makefile: 2
file content (18 lines) | stat: -rw-r--r-- 439 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "full", not(miri)))]

use tokio::io::AsyncReadExt;

#[tokio::test]
async fn repeat_poll_read_is_cooperative() {
    tokio::select! {
        biased;
        _ = async {
            loop {
                let mut buf = [0u8; 4096];
                tokio::io::repeat(0b101).read_exact(&mut buf).await.unwrap();
            }
        } => {},
        _ = tokio::task::yield_now() => {}
    }
}