diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-10-19 07:05:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-19 07:05:00 +0200 |
commit | 8d9fef3b8955eadfd4820455b422b5bec1cdad0a (patch) | |
tree | 7114c3e3c329c83ce1d9c90e8fab5c7104bd1579 /cli/graph_util.rs | |
parent | 5095af78018f1d77374bc06cbb58231e631056b9 (diff) |
refactor: add WatcherCommunicator helper struct (#20927)
This commit introduces "WatcherCommunicator" struct that
is used facilitate bi-directional communication between CLI
file watcher and the watched function.
Prerequisite for https://github.com/denoland/deno/pull/20876
Diffstat (limited to 'cli/graph_util.rs')
-rw-r--r-- | cli/graph_util.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 17437ca99..b90581a14 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -13,6 +13,7 @@ use crate::npm::CliNpmResolver; use crate::resolver::CliGraphResolver; use crate::tools::check; use crate::tools::check::TypeChecker; +use crate::util::file_watcher::WatcherCommunicator; use crate::util::sync::TaskQueue; use crate::util::sync::TaskQueuePermit; @@ -635,14 +636,14 @@ impl<'a> ModuleGraphUpdatePermit<'a> { #[derive(Clone, Debug)] pub struct FileWatcherReporter { - sender: tokio::sync::mpsc::UnboundedSender<Vec<PathBuf>>, + watcher_communicator: WatcherCommunicator, file_paths: Arc<Mutex<Vec<PathBuf>>>, } impl FileWatcherReporter { - pub fn new(sender: tokio::sync::mpsc::UnboundedSender<Vec<PathBuf>>) -> Self { + pub fn new(watcher_communicator: WatcherCommunicator) -> Self { Self { - sender, + watcher_communicator, file_paths: Default::default(), } } @@ -665,7 +666,10 @@ impl deno_graph::source::Reporter for FileWatcherReporter { } if modules_done == modules_total { - self.sender.send(file_paths.drain(..).collect()).unwrap(); + self + .watcher_communicator + .watch_paths(file_paths.drain(..).collect()) + .unwrap(); } } } |