1 use test_programs::wasi::cli::{stdin, stdout}; 2 main()3fn main() { 4 let stdin = stdin::get_stdin(); 5 let stdin_pollable = stdin.subscribe(); 6 stdin_pollable.block(); 7 assert!(stdin_pollable.ready(), "after blocking, pollable is ready"); 8 drop(stdin_pollable); 9 drop(stdin); 10 11 // Pollables can be used many times over their lifetime 12 let stdout = stdout::get_stdout(); 13 let stdout_pollable = stdout.subscribe(); 14 15 let chunk = [b'a'; 50]; 16 for _ in 1..10 { 17 stdout_pollable.block(); 18 assert!(stdout_pollable.ready(), "after blocking, pollable is ready"); 19 20 let n = stdout.check_write().unwrap() as usize; 21 assert!(n >= chunk.len()); 22 stdout.write(&chunk).unwrap(); 23 } 24 25 drop(stdout_pollable); 26 drop(stdout); 27 } 28