summaryrefslogtreecommitdiff
path: root/cli/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/state.rs')
-rw-r--r--cli/state.rs48
1 files changed, 36 insertions, 12 deletions
diff --git a/cli/state.rs b/cli/state.rs
index 856190134..c59eb8eeb 100644
--- a/cli/state.rs
+++ b/cli/state.rs
@@ -14,7 +14,6 @@ use deno_core::ErrBox;
use deno_core::ModuleLoader;
use deno_core::ModuleSpecifier;
use deno_core::Op;
-use deno_core::ResourceTable;
use deno_core::ZeroCopyBuf;
use futures::future::FutureExt;
use rand::rngs::StdRng;
@@ -64,7 +63,6 @@ pub struct StateInner {
pub next_worker_id: u32,
pub start_time: Instant,
pub seeded_rng: Option<StdRng>,
- pub resource_table: ResourceTable,
pub target_lib: TargetLib,
pub debug_type: DebugType,
}
@@ -81,7 +79,25 @@ impl State {
self.core_op(json_op(self.stateful_op(dispatcher)))
}
+ pub fn stateful_json_op2<D>(
+ &self,
+ dispatcher: D,
+ ) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
+ where
+ D: Fn(
+ &mut deno_core::Isolate,
+ &State,
+ Value,
+ Option<ZeroCopyBuf>,
+ ) -> Result<JsonOp, OpError>,
+ {
+ use crate::ops::json_op;
+ self.core_op(json_op(self.stateful_op2(dispatcher)))
+ }
+
/// Wrap core `OpDispatcher` to collect metrics.
+ // TODO(ry) this should be private. Is called by stateful_json_op or
+ // stateful_minimal_op
pub fn core_op<D>(
&self,
dispatcher: D,
@@ -142,19 +158,29 @@ impl State {
}
}
- /// This is a special function that provides `state` argument to dispatcher.
- pub fn stateful_minimal_op<D>(
+ pub fn stateful_minimal_op2<D>(
&self,
dispatcher: D,
- ) -> impl Fn(bool, i32, Option<ZeroCopyBuf>) -> MinimalOp
+ ) -> impl Fn(&mut deno_core::Isolate, &[u8], Option<ZeroCopyBuf>) -> Op
where
- D: Fn(&State, bool, i32, Option<ZeroCopyBuf>) -> MinimalOp,
+ D: Fn(
+ &mut deno_core::Isolate,
+ &State,
+ bool,
+ i32,
+ Option<ZeroCopyBuf>,
+ ) -> MinimalOp,
{
let state = self.clone();
- move |is_sync: bool,
- rid: i32,
- zero_copy: Option<ZeroCopyBuf>|
- -> MinimalOp { dispatcher(&state, is_sync, rid, zero_copy) }
+ self.core_op(crate::ops::minimal_op(
+ move |isolate: &mut deno_core::Isolate,
+ is_sync: bool,
+ rid: i32,
+ zero_copy: Option<ZeroCopyBuf>|
+ -> MinimalOp {
+ dispatcher(isolate, &state, is_sync, rid, zero_copy)
+ },
+ ))
}
/// This is a special function that provides `state` argument to dispatcher.
@@ -300,7 +326,6 @@ impl State {
next_worker_id: 0,
start_time: Instant::now(),
seeded_rng,
- resource_table: ResourceTable::default(),
target_lib: TargetLib::Main,
debug_type,
}));
@@ -336,7 +361,6 @@ impl State {
next_worker_id: 0,
start_time: Instant::now(),
seeded_rng,
- resource_table: ResourceTable::default(),
target_lib: TargetLib::Worker,
debug_type: DebugType::Dependent,
}));