From 326ffcefe09906560a03d3184a2ce76841448702 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 8 Sep 2018 12:36:02 +0300 Subject: Deal with deadlocks in a more principaled way --- crates/server/src/vfs.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'crates/server/src/vfs.rs') diff --git a/crates/server/src/vfs.rs b/crates/server/src/vfs.rs index 2699fc21e..c228f0b0a 100644 --- a/crates/server/src/vfs.rs +++ b/crates/server/src/vfs.rs @@ -3,11 +3,11 @@ use std::{ fs, }; -use crossbeam_channel::{Sender, Receiver, unbounded}; +use crossbeam_channel::{Sender, Receiver}; use walkdir::WalkDir; use { - thread_watcher::ThreadWatcher, + thread_watcher::{ThreadWatcher, worker_chan}, }; @@ -22,11 +22,11 @@ pub enum FileEventKind { Add(String), } -pub fn roots_loader() -> (Sender, Receiver<(PathBuf, Vec)>, ThreadWatcher) { - let (path_sender, path_receiver) = unbounded::(); - let (event_sender, event_receiver) = unbounded::<(PathBuf, Vec)>(); +pub fn roots_loader() -> ((Sender, Receiver<(PathBuf, Vec)>), ThreadWatcher) { + let (interface, input_receiver, output_sender) = + worker_chan::)>(128); let thread = ThreadWatcher::spawn("roots loader", move || { - path_receiver + input_receiver .into_iter() .map(|path| { debug!("loading {} ...", path.as_path().display()); @@ -34,10 +34,10 @@ pub fn roots_loader() -> (Sender, Receiver<(PathBuf, Vec)>, debug!("... loaded {}", path.as_path().display()); (path, events) }) - .for_each(|it| event_sender.send(it)) + .for_each(|it| output_sender.send(it)) }); - (path_sender, event_receiver, thread) + (interface, thread) } fn load_root(path: &Path) -> Vec { -- cgit v1.2.3