summaryrefslogtreecommitdiff
path: root/cli/state.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-01-21 17:50:06 +0100
committerGitHub <noreply@github.com>2020-01-21 17:50:06 +0100
commitecd1d3abb0cae9c7cbc1330cbaa035a5786e94d7 (patch)
tree73d4b12a06f5f6a6bc0e7168e0021efc3a2eda7c /cli/state.rs
parent229eb292f83dedbc32dc24f912841caf79a53e9c (diff)
refactor: split cli::Worker (#3735)
* cli::Worker is base struct to create specialized workers * add MainWorker * add CompilerWorker * refactor WebWorker to use Worker
Diffstat (limited to 'cli/state.rs')
-rw-r--r--cli/state.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/cli/state.rs b/cli/state.rs
index 4ad8241be..02c258280 100644
--- a/cli/state.rs
+++ b/cli/state.rs
@@ -35,6 +35,7 @@ use std::sync::Arc;
use std::sync::Mutex;
use std::sync::MutexGuard;
use std::time::Instant;
+use tokio::sync::Mutex as AsyncMutex;
/// Isolate cannot be passed between threads but ThreadSafeState can.
/// ThreadSafeState satisfies Send and Sync. So any state that needs to be
@@ -46,7 +47,7 @@ pub struct State {
pub global_state: ThreadSafeGlobalState,
pub permissions: Arc<Mutex<DenoPermissions>>,
pub main_module: Option<ModuleSpecifier>,
- pub worker_channels: Mutex<WorkerChannels>,
+ pub worker_channels: WorkerChannels,
/// When flags contains a `.import_map_path` option, the content of the
/// import map file will be resolved and set.
pub import_map: Option<ImportMap>,
@@ -203,11 +204,11 @@ impl ThreadSafeState {
let (out_tx, out_rx) = mpsc::channel::<Buf>(1);
let internal_channels = WorkerChannels {
sender: out_tx,
- receiver: in_rx,
+ receiver: Arc::new(AsyncMutex::new(in_rx)),
};
let external_channels = WorkerChannels {
sender: in_tx,
- receiver: out_rx,
+ receiver: Arc::new(AsyncMutex::new(out_rx)),
};
(internal_channels, external_channels)
}
@@ -241,7 +242,7 @@ impl ThreadSafeState {
main_module,
permissions,
import_map,
- worker_channels: Mutex::new(internal_channels),
+ worker_channels: internal_channels,
metrics: Metrics::default(),
global_timer: Mutex::new(GlobalTimer::new()),
workers: Mutex::new(HashMap::new()),