aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src/vfs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/server/src/vfs.rs')
-rw-r--r--crates/server/src/vfs.rs34
1 files changed, 16 insertions, 18 deletions
diff --git a/crates/server/src/vfs.rs b/crates/server/src/vfs.rs
index c228f0b0a..a1c1783f2 100644
--- a/crates/server/src/vfs.rs
+++ b/crates/server/src/vfs.rs
@@ -3,11 +3,10 @@ use std::{
3 fs, 3 fs,
4}; 4};
5 5
6use crossbeam_channel::{Sender, Receiver};
7use walkdir::WalkDir; 6use walkdir::WalkDir;
8 7
9use { 8use {
10 thread_watcher::{ThreadWatcher, worker_chan}, 9 thread_watcher::{Worker, ThreadWatcher},
11}; 10};
12 11
13 12
@@ -22,22 +21,21 @@ pub enum FileEventKind {
22 Add(String), 21 Add(String),
23} 22}
24 23
25pub fn roots_loader() -> ((Sender<PathBuf>, Receiver<(PathBuf, Vec<FileEvent>)>), ThreadWatcher) { 24pub fn roots_loader() -> (Worker<PathBuf, (PathBuf, Vec<FileEvent>)>, ThreadWatcher) {
26 let (interface, input_receiver, output_sender) = 25 Worker::<PathBuf, (PathBuf, Vec<FileEvent>)>::spawn(
27 worker_chan::<PathBuf, (PathBuf, Vec<FileEvent>)>(128); 26 "roots loader",
28 let thread = ThreadWatcher::spawn("roots loader", move || { 27 128, |input_receiver, output_sender| {
29 input_receiver 28 input_receiver
30 .into_iter() 29 .into_iter()
31 .map(|path| { 30 .map(|path| {
32 debug!("loading {} ...", path.as_path().display()); 31 debug!("loading {} ...", path.as_path().display());
33 let events = load_root(path.as_path()); 32 let events = load_root(path.as_path());
34 debug!("... loaded {}", path.as_path().display()); 33 debug!("... loaded {}", path.as_path().display());
35 (path, events) 34 (path, events)
36 }) 35 })
37 .for_each(|it| output_sender.send(it)) 36 .for_each(|it| output_sender.send(it))
38 }); 37 }
39 38 )
40 (interface, thread)
41} 39}
42 40
43fn load_root(path: &Path) -> Vec<FileEvent> { 41fn load_root(path: &Path) -> Vec<FileEvent> {