aboutsummaryrefslogtreecommitdiff
path: root/crates/vfs-notify/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-25 08:01:14 +0100
committerGitHub <[email protected]>2020-06-25 08:01:14 +0100
commit44d525d4e02a8a4f2e21cde3377c4c0bd9269b41 (patch)
treef486439231cff1dcd0ef118bbbe72708d9113d75 /crates/vfs-notify/src
parentfb70eb6e21da82c585d06e57c3c78f4aed4878f3 (diff)
parent5a184fe85517507fd3b07c6fb36b017e558665f7 (diff)
Merge #5048
5048: Unify code style for worker threads r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/vfs-notify/src')
-rw-r--r--crates/vfs-notify/src/lib.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs
index a2f4e0c5b..282cf0358 100644
--- a/crates/vfs-notify/src/lib.rs
+++ b/crates/vfs-notify/src/lib.rs
@@ -20,7 +20,7 @@ use walkdir::WalkDir;
20use crate::include::Include; 20use crate::include::Include;
21 21
22#[derive(Debug)] 22#[derive(Debug)]
23pub struct LoaderHandle { 23pub struct NotifyHandle {
24 // Relative order of fields below is significant. 24 // Relative order of fields below is significant.
25 sender: crossbeam_channel::Sender<Message>, 25 sender: crossbeam_channel::Sender<Message>,
26 _thread: jod_thread::JoinHandle, 26 _thread: jod_thread::JoinHandle,
@@ -32,12 +32,12 @@ enum Message {
32 Invalidate(AbsPathBuf), 32 Invalidate(AbsPathBuf),
33} 33}
34 34
35impl loader::Handle for LoaderHandle { 35impl loader::Handle for NotifyHandle {
36 fn spawn(sender: loader::Sender) -> LoaderHandle { 36 fn spawn(sender: loader::Sender) -> NotifyHandle {
37 let actor = LoaderActor::new(sender); 37 let actor = NotifyActor::new(sender);
38 let (sender, receiver) = unbounded::<Message>(); 38 let (sender, receiver) = unbounded::<Message>();
39 let thread = jod_thread::spawn(move || actor.run(receiver)); 39 let thread = jod_thread::spawn(move || actor.run(receiver));
40 LoaderHandle { sender, _thread: thread } 40 NotifyHandle { sender, _thread: thread }
41 } 41 }
42 fn set_config(&mut self, config: loader::Config) { 42 fn set_config(&mut self, config: loader::Config) {
43 self.sender.send(Message::Config(config)).unwrap() 43 self.sender.send(Message::Config(config)).unwrap()
@@ -52,10 +52,10 @@ impl loader::Handle for LoaderHandle {
52 52
53type NotifyEvent = notify::Result<notify::Event>; 53type NotifyEvent = notify::Result<notify::Event>;
54 54
55struct LoaderActor { 55struct NotifyActor {
56 sender: loader::Sender,
56 config: Vec<(AbsPathBuf, Include, bool)>, 57 config: Vec<(AbsPathBuf, Include, bool)>,
57 watched_paths: FxHashSet<AbsPathBuf>, 58 watched_paths: FxHashSet<AbsPathBuf>,
58 sender: loader::Sender,
59 // Drop order of fields bellow is significant, 59 // Drop order of fields bellow is significant,
60 watcher: Option<RecommendedWatcher>, 60 watcher: Option<RecommendedWatcher>,
61 watcher_receiver: Receiver<NotifyEvent>, 61 watcher_receiver: Receiver<NotifyEvent>,
@@ -67,19 +67,19 @@ enum Event {
67 NotifyEvent(NotifyEvent), 67 NotifyEvent(NotifyEvent),
68} 68}
69 69
70impl LoaderActor { 70impl NotifyActor {
71 fn new(sender: loader::Sender) -> LoaderActor { 71 fn new(sender: loader::Sender) -> NotifyActor {
72 let (watcher_sender, watcher_receiver) = unbounded(); 72 let (watcher_sender, watcher_receiver) = unbounded();
73 let watcher = log_notify_error(Watcher::new_immediate(move |event| { 73 let watcher = log_notify_error(Watcher::new_immediate(move |event| {
74 watcher_sender.send(event).unwrap() 74 watcher_sender.send(event).unwrap()
75 })); 75 }));
76 76
77 LoaderActor { 77 NotifyActor {
78 watcher,
79 watcher_receiver,
80 watched_paths: FxHashSet::default(),
81 sender, 78 sender,
82 config: Vec::new(), 79 config: Vec::new(),
80 watched_paths: FxHashSet::default(),
81 watcher,
82 watcher_receiver,
83 } 83 }
84 } 84 }
85 85