diff options
author | andy finch <andyfinch7@gmail.com> | 2019-06-13 23:43:54 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-06-13 20:43:54 -0700 |
commit | dc60fe9f300043f191286ef804a365e16e455f87 (patch) | |
tree | c6b74e9faa6f26745b8770a18d0ae46ee34f3774 /core/examples/http_bench.rs | |
parent | fdd2eb538327ee3f50fe2869320411191830c985 (diff) |
Refactor dispatch handling (#2452)
Promise id is now created in core and passed back to JS.
Diffstat (limited to 'core/examples/http_bench.rs')
-rw-r--r-- | core/examples/http_bench.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/core/examples/http_bench.rs b/core/examples/http_bench.rs index e8c5ec1b7..0f0cd6a4b 100644 --- a/core/examples/http_bench.rs +++ b/core/examples/http_bench.rs @@ -44,7 +44,7 @@ const OP_CLOSE: i32 = 5; #[derive(Clone, Debug, PartialEq)] pub struct Record { - pub promise_id: i32, + pub is_sync: i32, pub op_id: i32, pub arg: i32, pub result: i32, @@ -52,8 +52,8 @@ pub struct Record { impl Into<Buf> for Record { fn into(self) -> Buf { - let buf32 = vec![self.promise_id, self.op_id, self.arg, self.result] - .into_boxed_slice(); + let buf32 = + vec![self.is_sync, self.op_id, self.arg, self.result].into_boxed_slice(); let ptr = Box::into_raw(buf32) as *mut [u8; 16]; unsafe { Box::from_raw(ptr) } } @@ -65,7 +65,7 @@ impl From<&[u8]> for Record { let ptr = s.as_ptr() as *const i32; let ints = unsafe { std::slice::from_raw_parts(ptr, 4) }; Record { - promise_id: ints[0], + is_sync: ints[0], op_id: ints[1], arg: ints[2], result: ints[3], @@ -81,7 +81,7 @@ impl From<Buf> for Record { let ints: Box<[i32]> = unsafe { Box::from_raw(ptr) }; assert_eq!(ints.len(), 4); Record { - promise_id: ints[0], + is_sync: ints[0], op_id: ints[1], arg: ints[2], result: ints[3], @@ -92,7 +92,7 @@ impl From<Buf> for Record { #[test] fn test_record_from() { let r = Record { - promise_id: 1, + is_sync: 1, op_id: 2, arg: 3, result: 4, @@ -111,9 +111,9 @@ fn test_record_from() { pub type HttpBenchOp = dyn Future<Item = i32, Error = std::io::Error> + Send; -fn dispatch(control: &[u8], zero_copy_buf: Option<PinnedBuf>) -> Op { +fn dispatch(control: &[u8], zero_copy_buf: Option<PinnedBuf>) -> CoreOp { let record = Record::from(control); - let is_sync = record.promise_id == 0; + let is_sync = record.is_sync == 1; let http_bench_op = match record.op_id { OP_LISTEN => { assert!(is_sync); |