diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-03-14 23:14:15 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-14 18:44:15 +0100 |
commit | b4e42953e1d243f2eda20e5be6b845d60b7bf688 (patch) | |
tree | 10b3bfff165f9c04f9174c7c399d44b9b724c3b3 /runtime/ops/worker_host.rs | |
parent | 4e3ed37037a2aa1edeac260dc3463a81d9cf9b88 (diff) |
feat(core): codegen ops (#13861)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
Diffstat (limited to 'runtime/ops/worker_host.rs')
-rw-r--r-- | runtime/ops/worker_host.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index 1213da6d2..cebce81a4 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -13,8 +13,8 @@ use crate::web_worker::WorkerControlEvent; use crate::web_worker::WorkerId; use deno_core::error::AnyError; use deno_core::futures::future::LocalFutureObj; -use deno_core::op_async; -use deno_core::op_sync; +use deno_core::op; + use deno_core::serde::Deserialize; use deno_core::Extension; use deno_core::ModuleSpecifier; @@ -122,14 +122,11 @@ pub fn init( Ok(()) }) .ops(vec![ - ("op_create_worker", op_sync(op_create_worker)), - ( - "op_host_terminate_worker", - op_sync(op_host_terminate_worker), - ), - ("op_host_post_message", op_sync(op_host_post_message)), - ("op_host_recv_ctrl", op_async(op_host_recv_ctrl)), - ("op_host_recv_message", op_async(op_host_recv_message)), + op_create_worker::decl(), + op_host_terminate_worker::decl(), + op_host_post_message::decl(), + op_host_recv_ctrl::decl(), + op_host_recv_message::decl(), ]) .build() } @@ -147,6 +144,7 @@ pub struct CreateWorkerArgs { } /// Create worker as the host +#[op] fn op_create_worker( state: &mut OpState, args: CreateWorkerArgs, @@ -263,6 +261,7 @@ fn op_create_worker( Ok(worker_id) } +#[op] fn op_host_terminate_worker( state: &mut OpState, id: WorkerId, @@ -317,6 +316,7 @@ fn close_channel( } /// Get control event from guest worker as host +#[op] async fn op_host_recv_ctrl( state: Rc<RefCell<OpState>>, id: WorkerId, @@ -348,6 +348,7 @@ async fn op_host_recv_ctrl( Ok(WorkerControlEvent::Close) } +#[op] async fn op_host_recv_message( state: Rc<RefCell<OpState>>, id: WorkerId, @@ -373,6 +374,7 @@ async fn op_host_recv_message( } /// Post message to guest worker as host +#[op] fn op_host_post_message( state: &mut OpState, id: WorkerId, |