diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-01-12 08:50:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 23:50:02 -0800 |
commit | 275a5c65a20529cd4a3d775b8d8c6e9b261c76b1 (patch) | |
tree | 9f861e36e70be809d5586128a24b9f7b4332e09e /cli/file_watcher.rs | |
parent | 36ff7bdf575e0547fabd8957ee778cc4224d5956 (diff) |
upgrade: tokio 1.0 (#8779)
Co-authored-by: Bert Belder <bertbelder@gmail.com>
Diffstat (limited to 'cli/file_watcher.rs')
-rw-r--r-- | cli/file_watcher.rs | 10 |
1 files changed, 5 insertions, 5 deletions
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<T> = Pin<Box<dyn Future<Output = T>>>; struct Debounce { - delay: Delay, + sleep: Pin<Box<dyn Future<Output = ()>>>, event_detected: Arc<AtomicBool>, } 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, |