From 7b51fe6ba745eda5ded7e4059fd62f92386ce6a0 Mon Sep 17 00:00:00 2001 From: jeb Date: Mon, 2 Jul 2018 15:14:14 -0600 Subject: [PATCH] switch watcher to raw_watcher hopefully helps catch reload conditions more quickly, and notify won't do any of its extra processing (that we ignore anyway) --- contrib/lib/src/templates/fairing.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/contrib/lib/src/templates/fairing.rs b/contrib/lib/src/templates/fairing.rs index 83e3fb95f2..58a735c223 100644 --- a/contrib/lib/src/templates/fairing.rs +++ b/contrib/lib/src/templates/fairing.rs @@ -33,11 +33,10 @@ mod context { use std::ops::{Deref, DerefMut}; use std::sync::{RwLock, Mutex}; use std::sync::mpsc::{channel, Receiver}; - use std::time::Duration; use super::{Context, Engines}; - use self::notify::{watcher, DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher}; + use self::notify::{raw_watcher, RawEvent, RecommendedWatcher, RecursiveMode, Watcher}; /// Wraps a Context. With `cfg(debug_assertions)` active, this structure /// additionally provides a method to reload the context at runtime. @@ -45,14 +44,14 @@ mod context { /// The current template context, inside an RwLock so it can be updated context: RwLock, /// A filesystem watcher and the receive queue for its events - watcher: Option<(RecommendedWatcher, Mutex>)>, + watcher: Option<(RecommendedWatcher, Mutex>)>, } impl ContextManager { pub fn new(ctxt: Context) -> ContextManager { let (tx, rx) = channel(); - let watcher = if let Ok(mut watcher) = watcher(tx, Duration::from_secs(1)) { + let watcher = if let Ok(mut watcher) = raw_watcher(tx) { if watcher.watch(ctxt.root.clone(), RecursiveMode::Recursive).is_ok() { Some((watcher, Mutex::new(rx))) } else {