summaryrefslogtreecommitdiff
path: root/cli/state.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-02-18 14:47:11 -0500
committerGitHub <noreply@github.com>2020-02-18 14:47:11 -0500
commit3d5bed35e032ee20e4fe34cad925202c6f0c0d3e (patch)
tree2f9ad905c9e55bd80832055ac7ef41c94bf419bc /cli/state.rs
parent08dcf6bff73bbe579769ccd0f135ed4af919ea48 (diff)
refactor: remove run_worker_loop (#4028)
* remove run_worker_loop, impl poll for WebWorker * store JoinHandle to worker thread
Diffstat (limited to 'cli/state.rs')
-rw-r--r--cli/state.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/cli/state.rs b/cli/state.rs
index 93eaaab43..7f342a9b1 100644
--- a/cli/state.rs
+++ b/cli/state.rs
@@ -30,8 +30,7 @@ use std::path::Path;
use std::pin::Pin;
use std::rc::Rc;
use std::str;
-use std::sync::atomic::AtomicUsize;
-use std::sync::atomic::Ordering;
+use std::thread::JoinHandle;
use std::time::Instant;
#[derive(Clone)]
@@ -54,8 +53,8 @@ pub struct StateInner {
pub import_map: Option<ImportMap>,
pub metrics: Metrics,
pub global_timer: GlobalTimer,
- pub workers: HashMap<u32, WorkerHandle>,
- pub next_worker_id: AtomicUsize,
+ pub workers: HashMap<u32, (JoinHandle<()>, WorkerHandle)>,
+ pub next_worker_id: u32,
pub start_time: Instant,
pub seeded_rng: Option<StdRng>,
pub resource_table: ResourceTable,
@@ -231,7 +230,7 @@ impl State {
metrics: Metrics::default(),
global_timer: GlobalTimer::new(),
workers: HashMap::new(),
- next_worker_id: AtomicUsize::new(0),
+ next_worker_id: 0,
start_time: Instant::now(),
seeded_rng,
@@ -267,7 +266,7 @@ impl State {
metrics: Metrics::default(),
global_timer: GlobalTimer::new(),
workers: HashMap::new(),
- next_worker_id: AtomicUsize::new(0),
+ next_worker_id: 0,
start_time: Instant::now(),
seeded_rng,
@@ -278,14 +277,6 @@ impl State {
Ok(Self(state))
}
- pub fn add_child_worker(&self, handle: WorkerHandle) -> u32 {
- let mut inner_state = self.borrow_mut();
- let worker_id =
- inner_state.next_worker_id.fetch_add(1, Ordering::Relaxed) as u32;
- inner_state.workers.insert(worker_id, handle);
- worker_id
- }
-
#[inline]
pub fn check_read(&self, path: &Path) -> Result<(), ErrBox> {
self.borrow().permissions.check_read(path)