From 379a096de9ad06c23347b76a54d9cc22aee80f6a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 25 Jun 2020 17:14:11 +0200 Subject: Refactor main_loop --- crates/vfs-notify/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/vfs-notify') diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index 68fdb8cb0..25ba8d798 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -82,7 +82,12 @@ impl NotifyActor { watcher_receiver, } } - + fn next_event(&self, receiver: &Receiver) -> Option { + select! { + recv(receiver) -> it => it.ok().map(Event::Message), + recv(&self.watcher_receiver) -> it => Some(Event::NotifyEvent(it.unwrap())), + } + } fn run(mut self, inbox: Receiver) { while let Some(event) = self.next_event(&inbox) { log::debug!("vfs-notify event: {:?}", event); @@ -154,12 +159,6 @@ impl NotifyActor { } } } - fn next_event(&self, receiver: &Receiver) -> Option { - select! { - recv(receiver) -> it => it.ok().map(Event::Message), - recv(&self.watcher_receiver) -> it => Some(Event::NotifyEvent(it.unwrap())), - } - } fn load_entry( &mut self, entry: loader::Entry, -- cgit v1.2.3