From 275a5c65a20529cd4a3d775b8d8c6e9b261c76b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 12 Jan 2021 08:50:02 +0100 Subject: upgrade: tokio 1.0 (#8779) Co-authored-by: Bert Belder --- cli/file_watcher.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cli/file_watcher.rs') diff --git a/cli/file_watcher.rs b/cli/file_watcher.rs index 655cff534..699a27864 100644 --- a/cli/file_watcher.rs +++ b/cli/file_watcher.rs @@ -18,21 +18,21 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::time::Duration; use tokio::select; -use tokio::time::{delay_for, Delay}; +use tokio::time::sleep; const DEBOUNCE_INTERVAL_MS: Duration = Duration::from_millis(200); type FileWatcherFuture = Pin>>; struct Debounce { - delay: Delay, + sleep: Pin>>, event_detected: Arc, } impl Debounce { fn new() -> Self { Self { - delay: delay_for(DEBOUNCE_INTERVAL_MS), + sleep: sleep(DEBOUNCE_INTERVAL_MS).boxed_local(), event_detected: Arc::new(AtomicBool::new(false)), } } @@ -52,9 +52,9 @@ impl Stream for Debounce { inner.event_detected.store(false, Ordering::Relaxed); Poll::Ready(Some(())) } else { - match inner.delay.poll_unpin(cx) { + match inner.sleep.poll_unpin(cx) { Poll::Ready(_) => { - inner.delay = delay_for(DEBOUNCE_INTERVAL_MS); + inner.sleep = sleep(DEBOUNCE_INTERVAL_MS).boxed_local(); Poll::Pending } Poll::Pending => Poll::Pending, -- cgit v1.2.3