A better async Wrapper


Back to index

What signals?

If you're on Linux

inotify-rs

let mut notify = Inotify::init().expect("failed to initialise Inotify structure");
notify
    .add_watch(&path, WatchMask::MOVE)
    .expect(&format!("failed to watch directory {:?}", path));
If you're on macOS/ BSD

kqueue

let mut watcher = kqueue::Watcher::new()?;
watcher.add_filename(path, kqueue::EventFilter::EVFILT_VNODE, kqueue::FilterFlag::NOTE_RENAME)?;

Alternatively

  • async-io provides a Timer type
  • Instead of busy-waking (waking a future after every poll), use a fixed Timer to reduce system load.
use async_io::Timer;
use std::time::Duration;

Timer::after(Duration::from_secs(1)).await;

Back to index