pub fn new(duration: Duration) -> Self {
            let shared_state = Arc::new(Mutex::new(SharedState {
                completed: false,
                waker: None,
            }));

            // Spawn the new thread
            let thread_shared_state = shared_state.clone();
            std::thread::spawn(move || {
                std::thread::sleep(duration);
                let mut shared_state = thread_shared_state.lock().unwrap();
                // Signal that the timer has completed and wake up the last
                // task on which the future was polled, if one exists.
                shared_state.completed = true;
                if let Some(waker) = shared_state.waker.take() {
                    waker.wake()
                }
            });

            ThrottleTimerFuture { shared_state }
        }
/// Create a new `TimerFuture` which will complete after the provided
/// timeout.
Create a new `TimerFuture` which will complete after the provided
timeout.
Create a new ` TimerFuture ` which will complete after the provided timeout .
pub fn new(duration: Duration) -> Self {
            let shared_state = Arc::new(Mutex::new(SharedState {
                completed: false,
                waker: None,
            }));
            // Spawn the new thread
            let thread_shared_state = shared_state.clone();
            std::thread::spawn(move || {
                std::thread::sleep(duration);
                let mut shared_state = thread_shared_state.lock().unwrap();
                // Signal that the timer has completed and wake up the last
                // task on which the future was polled, if one exists.
                shared_state.completed = true;
                if let Some(waker) = shared_state.waker.take() {
                    waker.wake()
                }
            });
            ThrottleTimerFuture { shared_state }
        }
pub fn new ( duration : Duration ) -> Self { let shared_state = Arc :: new ( Mutex :: new ( SharedState { completed : false , waker : None , } ) ) ; // Spawn the new thread let thread_shared_state = shared_state . clone ( ) ; std :: thread :: spawn ( move | | { std :: thread :: sleep ( duration ) ; let mut shared_state = thread_shared_state . lock ( ) . unwrap ( ) ; // Signal that the timer has completed and wake up the last // task on which the future was polled, if one exists. shared_state . completed = true ; if let Some ( waker ) = shared_state . waker . take ( ) { waker . wake ( ) } } ) ; ThrottleTimerFuture { shared_state } }
Create a new `TimerFuture` which will complete after the provided
timeout.
Create a new ` TimerFuture ` which will complete after the provided timeout .
duration
Duration
duration
Duration