diff options
Diffstat (limited to 'runtime/worker.rs')
| -rw-r--r-- | runtime/worker.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/runtime/worker.rs b/runtime/worker.rs index 4c38d232f..94c05cd82 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -35,6 +35,18 @@ use std::task::Poll; pub type FormatJsErrorFn = dyn Fn(&JsError) -> String + Sync + Send; +#[derive(Clone)] +pub struct ExitCode(Arc<AtomicI32>); + +impl ExitCode { + pub fn get(&self) -> i32 { + self.0.load(Relaxed) + } + + pub fn set(&mut self, code: i32) { + self.0.store(code, Relaxed); + } +} /// This worker is created and used by almost all /// subcommands in Deno executable. /// @@ -45,6 +57,7 @@ pub type FormatJsErrorFn = dyn Fn(&JsError) -> String + Sync + Send; pub struct MainWorker { pub js_runtime: JsRuntime, should_break_on_first_statement: bool, + exit_code: ExitCode, } pub struct WorkerOptions { @@ -98,6 +111,7 @@ impl MainWorker { Ok(()) }) .build(); + let exit_code = ExitCode(Arc::new(AtomicI32::new(0))); // Internal modules let mut extensions: Vec<Extension> = vec