1 #![warn(rust_2018_idioms)] 2 #![cfg(feature = "full")] 3 4 use tokio::time::{self, throttle}; 5 use tokio_test::*; 6 7 use std::time::Duration; 8 9 #[tokio::test] usage()10async fn usage() { 11 time::pause(); 12 13 let mut stream = task::spawn(throttle( 14 Duration::from_millis(100), 15 futures::stream::repeat(()), 16 )); 17 18 assert_ready!(stream.poll_next()); 19 assert_pending!(stream.poll_next()); 20 21 time::advance(Duration::from_millis(90)).await; 22 23 assert_pending!(stream.poll_next()); 24 25 time::advance(Duration::from_millis(101)).await; 26 27 assert!(stream.is_woken()); 28 29 assert_ready!(stream.poll_next()); 30 } 31