diff --git a/src/poll.rs b/src/poll.rs index e7a050ad..4ca721a6 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -43,13 +43,10 @@ fn emit_event(event_handler: &Mutex, res: Result) { } impl PollWatcher { - /// Create a [PollWatcher] which polls every `delay` milliseconds - pub fn with_delay( - event_handler: Arc>, - delay: Duration, - ) -> Result { + /// Create a new [PollWatcher] and set the poll frequency to `delay`. + pub fn with_delay(event_handler: F, delay: Duration) -> Result { let mut p = PollWatcher { - event_handler, + event_handler: Arc::new(Mutex::new(event_handler)), watches: Arc::new(Mutex::new(HashMap::new())), open: Arc::new(AtomicBool::new(true)), delay, @@ -276,8 +273,10 @@ impl PollWatcher { impl Watcher for PollWatcher { /// Create a new [PollWatcher]. + /// + /// The default poll frequency is 30 seconds. + /// Use [with_delay] to manually set the poll frequency. fn new(event_handler: F) -> Result { - let event_handler = Arc::new(Mutex::new(event_handler)); let delay = Duration::from_secs(30); Self::with_delay(event_handler, delay) }