diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-06-08 17:45:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-08 17:45:38 +0200 |
commit | ba13b8e2a9efff13e4a7c0659bb2ed184cc4e683 (patch) | |
tree | 787dfd5f56557cfb6f25008924118ef0c53e1ab7 /runtime/ops/worker_host.rs | |
parent | 4911acb148a4b7b22a205772e2e9c410ee5be9c7 (diff) |
refactor: ensure exit code reference is passed to all workers (#14814)
Diffstat (limited to 'runtime/ops/worker_host.rs')
-rw-r--r-- | runtime/ops/worker_host.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index d869e5871..9860f7cb5 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -11,6 +11,7 @@ use crate::web_worker::WebWorkerHandle; use crate::web_worker::WebWorkerType; use crate::web_worker::WorkerControlEvent; use crate::web_worker::WorkerId; +use crate::worker::ExitCode; use crate::worker::FormatJsErrorFn; use deno_core::error::AnyError; use deno_core::futures::future::LocalFutureObj; @@ -27,7 +28,6 @@ use log::debug; use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; -use std::sync::atomic::AtomicI32; use std::sync::Arc; pub struct CreateWebWorkerArgs { @@ -37,7 +37,7 @@ pub struct CreateWebWorkerArgs { pub permissions: Permissions, pub main_module: ModuleSpecifier, pub worker_type: WebWorkerType, - pub maybe_exit_code: Option<Arc<AtomicI32>>, + pub exit_code: ExitCode, } pub type CreateWebWorkerCb = dyn Fn(CreateWebWorkerArgs) -> (WebWorker, SendableWebWorkerHandle) @@ -171,11 +171,7 @@ fn op_create_worker( parent_permissions.clone() }; let parent_permissions = parent_permissions.clone(); - // `try_borrow` here, because worker might have been started without - // access to `Deno` namespace. - // TODO(bartlomieju): can a situation happen when parent doesn't - // have access to `exit_code` but the child does? - let maybe_exit_code = state.try_borrow::<Arc<AtomicI32>>().cloned(); + let exit_code = state.borrow::<ExitCode>().clone(); let worker_id = state.take::<WorkerId>(); let create_web_worker_cb = state.take::<CreateWebWorkerCbHolder>(); state.put::<CreateWebWorkerCbHolder>(create_web_worker_cb.clone()); @@ -211,7 +207,7 @@ fn op_create_worker( permissions: worker_permissions, main_module: module_specifier.clone(), worker_type, - maybe_exit_code, + exit_code, }); // Send thread safe handle from newly created worker to host thread |