diff options
author | andy finch <andyfinch7@gmail.com> | 2019-04-11 10:58:31 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-04-11 10:58:31 -0400 |
commit | 960ee5257a7b38c6b3b59a3dca670c7c1771996f (patch) | |
tree | d4832e3f607eafa38900d65c498fb6344e5f0041 /cli/ops.rs | |
parent | 1034d9723db59b6b7354d6d9804735ebe333d4a1 (diff) |
Improve op dispatch (#2088)
Diffstat (limited to 'cli/ops.rs')
-rw-r--r-- | cli/ops.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/cli/ops.rs b/cli/ops.rs index ce8299136..0d752e226 100644 --- a/cli/ops.rs +++ b/cli/ops.rs @@ -63,7 +63,7 @@ type OpCreator = fn(state: &ThreadSafeState, base: &msg::Base<'_>, data: deno_buf) -> Box<OpWithError>; -type OpSelector = fn(inner_type: msg::Any) -> Option<OpCreator>; +pub type OpSelector = fn(inner_type: msg::Any) -> Option<OpCreator>; #[inline] fn empty_buf() -> Buf { @@ -142,6 +142,17 @@ pub fn dispatch_all( (base.sync(), boxed_op) } +pub fn op_selector_compiler(inner_type: msg::Any) -> Option<OpCreator> { + match inner_type { + msg::Any::FetchModuleMetaData => Some(op_fetch_module_meta_data), + msg::Any::WorkerGetMessage => Some(op_worker_get_message), + msg::Any::WorkerPostMessage => Some(op_worker_post_message), + msg::Any::Exit => Some(op_exit), + msg::Any::Start => Some(op_start), + _ => None, + } +} + /// Standard ops set for most isolates pub fn op_selector_std(inner_type: msg::Any) -> Option<OpCreator> { match inner_type { @@ -192,9 +203,7 @@ pub fn op_selector_std(inner_type: msg::Any) -> Option<OpCreator> { msg::Any::Write => Some(op_write), // TODO(ry) split these out so that only the appropriate Workers can access - // them. Only the compiler worker should be able to access - // FetchModuleMetaData. - msg::Any::FetchModuleMetaData => Some(op_fetch_module_meta_data), + // them. msg::Any::WorkerGetMessage => Some(op_worker_get_message), msg::Any::WorkerPostMessage => Some(op_worker_post_message), @@ -1860,6 +1869,7 @@ fn op_create_worker( let child_state = ThreadSafeState::new( parent_state.flags.clone(), parent_state.argv.clone(), + op_selector_std, ); let rid = child_state.resource.rid; let name = format!("USER-WORKER-{}", specifier); |