summaryrefslogtreecommitdiff
path: root/cli/ops/web_worker.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-09-10 09:57:45 -0400
committerGitHub <noreply@github.com>2020-09-10 09:57:45 -0400
commit7c2e7c660804afca823d60e6496aa853f75db16c (patch)
treeb7746b181c1564c6b1abd2e906662f9e6b008417 /cli/ops/web_worker.rs
parent6f70e6e72ba2d5c1de7495adac37c1e4f4e86b24 (diff)
Use gotham-like state for ops (#7385)
Provides a concrete state type that can be dynamically added. This is necessary for op crates. * renames BasicState to OpState * async ops take `Rc<RefCell<OpState>>` * sync ops take `&mut OpState` * removes `OpRegistry`, `OpRouter` traits * `get_error_class_fn` moved to OpState * ResourceTable moved to OpState
Diffstat (limited to 'cli/ops/web_worker.rs')
-rw-r--r--cli/ops/web_worker.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/cli/ops/web_worker.rs b/cli/ops/web_worker.rs
index 9d8140d7b..fad0b9df7 100644
--- a/cli/ops/web_worker.rs
+++ b/cli/ops/web_worker.rs
@@ -1,20 +1,18 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-use crate::state::State;
use crate::web_worker::WebWorkerHandle;
use crate::worker::WorkerEvent;
-use deno_core::OpRegistry;
use futures::channel::mpsc;
-use std::rc::Rc;
pub fn init(
- s: &Rc<State>,
- sender: &mpsc::Sender<WorkerEvent>,
+ rt: &mut deno_core::JsRuntime,
+ sender: mpsc::Sender<WorkerEvent>,
handle: WebWorkerHandle,
) {
// Post message to host as guest worker.
let sender_ = sender.clone();
- s.register_op_json_sync(
+ super::reg_json_sync(
+ rt,
"op_worker_post_message",
move |_state, _args, bufs| {
assert_eq!(bufs.len(), 1, "Invalid number of arguments");
@@ -28,10 +26,9 @@ pub fn init(
);
// Notify host that guest worker closes.
- let sender_ = sender.clone();
- s.register_op_json_sync("op_worker_close", move |_state, _args, _bufs| {
+ super::reg_json_sync(rt, "op_worker_close", move |_state, _args, _bufs| {
// Notify parent that we're finished
- sender_.clone().close_channel();
+ sender.clone().close_channel();
// Terminate execution of current worker
handle.terminate();
Ok(json!({}))