summaryrefslogtreecommitdiff
path: root/core/examples/http_bench.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2020-04-19 23:54:46 -0400
committerGitHub <noreply@github.com>2020-04-19 23:54:46 -0400
commitc1ec042a0011eeba2480b892a335ca7804c59180 (patch)
tree02d9595a3a6be9fb646171be29f59a3c0f74f12f /core/examples/http_bench.rs
parent4e3532fe7b61a1050b00611081cc83af8b02de70 (diff)
Modify op dispatcher to include &mut Isolate argument (#4821)
- Removes unnecessary RwLock and Rc around the op registry table - Preparation to move resource_table to deno_core::Isolate. - Towards #3453, #4222
Diffstat (limited to 'core/examples/http_bench.rs')
-rw-r--r--core/examples/http_bench.rs64
1 files changed, 34 insertions, 30 deletions
diff --git a/core/examples/http_bench.rs b/core/examples/http_bench.rs
index 27fefc8bb..9e5808043 100644
--- a/core/examples/http_bench.rs
+++ b/core/examples/http_bench.rs
@@ -111,20 +111,22 @@ impl Isolate {
F: 'static + Fn(State, u32, Option<ZeroCopyBuf>) -> Result<u32, Error>,
{
let state = self.state.clone();
- let core_handler =
- move |control_buf: &[u8], zero_copy_buf: Option<ZeroCopyBuf>| -> Op {
- let state = state.clone();
- let record = Record::from(control_buf);
- let is_sync = record.promise_id == 0;
- assert!(is_sync);
-
- let result: i32 = match handler(state, record.rid, zero_copy_buf) {
- Ok(r) => r as i32,
- Err(_) => -1,
- };
- let buf = RecordBuf::from(Record { result, ..record })[..].into();
- Op::Sync(buf)
+ let core_handler = move |_isolate: &mut deno_core::Isolate,
+ control_buf: &[u8],
+ zero_copy_buf: Option<ZeroCopyBuf>|
+ -> Op {
+ let state = state.clone();
+ let record = Record::from(control_buf);
+ let is_sync = record.promise_id == 0;
+ assert!(is_sync);
+
+ let result: i32 = match handler(state, record.rid, zero_copy_buf) {
+ Ok(r) => r as i32,
+ Err(_) => -1,
};
+ let buf = RecordBuf::from(Record { result, ..record })[..].into();
+ Op::Sync(buf)
+ };
self.core_isolate.register_op(name, core_handler);
}
@@ -139,25 +141,27 @@ impl Isolate {
<F::Ok as TryInto<i32>>::Error: Debug,
{
let state = self.state.clone();
- let core_handler =
- move |control_buf: &[u8], zero_copy_buf: Option<ZeroCopyBuf>| -> Op {
- let state = state.clone();
- let record = Record::from(control_buf);
- let is_sync = record.promise_id == 0;
- assert!(!is_sync);
-
- let fut = async move {
- let op = handler(state, record.rid, zero_copy_buf);
- let result = op
- .map_ok(|r| r.try_into().expect("op result does not fit in i32"))
- .unwrap_or_else(|_| -1)
- .await;
- RecordBuf::from(Record { result, ..record })[..].into()
- };
-
- Op::Async(fut.boxed_local())
+ let core_handler = move |_isolate: &mut deno_core::Isolate,
+ control_buf: &[u8],
+ zero_copy_buf: Option<ZeroCopyBuf>|
+ -> Op {
+ let state = state.clone();
+ let record = Record::from(control_buf);
+ let is_sync = record.promise_id == 0;
+ assert!(!is_sync);
+
+ let fut = async move {
+ let op = handler(state, record.rid, zero_copy_buf);
+ let result = op
+ .map_ok(|r| r.try_into().expect("op result does not fit in i32"))
+ .unwrap_or_else(|_| -1)
+ .await;
+ RecordBuf::from(Record { result, ..record })[..].into()
};
+ Op::Async(fut.boxed_local())
+ };
+
self.core_isolate.register_op(name, core_handler);
}
}