From 3e7afb8918fd0f6cedf839a7ebaae6aaee5e66ad Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Fri, 13 May 2022 10:36:31 +0200 Subject: chore(runtime): Make some ops in ext and runtime infallible. (#14589) Co-authored-by: Aaron O'Mullan --- runtime/ops/os.rs | 5 ++--- runtime/ops/web_worker.rs | 7 +++---- runtime/ops/worker_host.rs | 6 +----- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'runtime/ops') diff --git a/runtime/ops/os.rs b/runtime/ops/os.rs index ad2ff60ea..c74a423ab 100644 --- a/runtime/ops/os.rs +++ b/runtime/ops/os.rs @@ -103,13 +103,12 @@ fn op_delete_env(state: &mut OpState, key: String) -> Result<(), AnyError> { } #[op] -fn op_set_exit_code(state: &mut OpState, code: i32) -> Result<(), AnyError> { +fn op_set_exit_code(state: &mut OpState, code: i32) { state.borrow_mut::>().store(code, Relaxed); - Ok(()) } #[op] -fn op_exit(state: &mut OpState) -> Result<(), AnyError> { +fn op_exit(state: &mut OpState) { let code = state.borrow::>().load(Relaxed); std::process::exit(code) } diff --git a/runtime/ops/web_worker.rs b/runtime/ops/web_worker.rs index 4137217bd..184ebfddb 100644 --- a/runtime/ops/web_worker.rs +++ b/runtime/ops/web_worker.rs @@ -55,16 +55,15 @@ async fn op_worker_recv_message( } #[op] -fn op_worker_close(state: &mut OpState) -> Result<(), AnyError> { +fn op_worker_close(state: &mut OpState) { // Notify parent that we're finished let mut handle = state.borrow_mut::().clone(); handle.terminate(); - Ok(()) } #[op] -fn op_worker_get_type(state: &mut OpState) -> Result { +fn op_worker_get_type(state: &mut OpState) -> WebWorkerType { let handle = state.borrow::().clone(); - Ok(handle.worker_type) + handle.worker_type } diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index bd1f1e3f5..f8831d4e9 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -258,16 +258,12 @@ fn op_create_worker( } #[op] -fn op_host_terminate_worker( - state: &mut OpState, - id: WorkerId, -) -> Result<(), AnyError> { +fn op_host_terminate_worker(state: &mut OpState, id: WorkerId) { if let Some(worker_thread) = state.borrow_mut::().remove(&id) { worker_thread.terminate(); } else { debug!("tried to terminate non-existent worker {}", id); } - Ok(()) } enum WorkerChannel { -- cgit v1.2.3