mirror of https://github.com/rwf2/Rocket.git
Ensure 'ContextManager' is 'Sync' on all platforms.
This commit is contained in:
parent
d011cd63fc
commit
95cbc241db
|
@ -46,7 +46,7 @@ mod context {
|
||||||
/// The current template context, inside an RwLock so it can be updated.
|
/// The current template context, inside an RwLock so it can be updated.
|
||||||
context: RwLock<Context>,
|
context: RwLock<Context>,
|
||||||
/// A filesystem watcher and the receive queue for its events.
|
/// A filesystem watcher and the receive queue for its events.
|
||||||
watcher: Option<(RecommendedWatcher, Mutex<Receiver<RawEvent>>)>,
|
watcher: Option<Mutex<(RecommendedWatcher, Receiver<RawEvent>)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContextManager {
|
impl ContextManager {
|
||||||
|
@ -55,7 +55,7 @@ mod context {
|
||||||
|
|
||||||
let watcher = if let Ok(mut watcher) = raw_watcher(tx) {
|
let watcher = if let Ok(mut watcher) = raw_watcher(tx) {
|
||||||
if watcher.watch(ctxt.root.clone(), RecursiveMode::Recursive).is_ok() {
|
if watcher.watch(ctxt.root.clone(), RecursiveMode::Recursive).is_ok() {
|
||||||
Some((watcher, Mutex::new(rx)))
|
Some(Mutex::new((watcher, rx)))
|
||||||
} else {
|
} else {
|
||||||
warn!("Could not monitor the templates directory for changes.");
|
warn!("Could not monitor the templates directory for changes.");
|
||||||
warn_!("Live template reload will be unavailable");
|
warn_!("Live template reload will be unavailable");
|
||||||
|
@ -87,9 +87,9 @@ mod context {
|
||||||
/// again.
|
/// again.
|
||||||
pub fn reload_if_needed<F: Fn(&mut Engines)>(&self, custom_callback: F) {
|
pub fn reload_if_needed<F: Fn(&mut Engines)>(&self, custom_callback: F) {
|
||||||
self.watcher.as_ref().map(|w| {
|
self.watcher.as_ref().map(|w| {
|
||||||
let rx = w.1.lock().expect("receive queue");
|
let rx_lock = w.lock().expect("receive queue lock");
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
while let Ok(_) = rx.try_recv() {
|
while let Ok(_) = rx_lock.1.try_recv() {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue