diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-05-01 18:22:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-01 18:22:32 -0400 |
commit | c171813e894f0759abb1b80413aa2a24dbad079b (patch) | |
tree | 25ab50f1d9a37f827f8cf063c181512f3d961edb /core/examples/http_bench.rs | |
parent | 2f4fefd0f6a5c43724ee8d19b008018c28c7c323 (diff) |
core: express op as enum (#2255)
Diffstat (limited to 'core/examples/http_bench.rs')
-rw-r--r-- | core/examples/http_bench.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/core/examples/http_bench.rs b/core/examples/http_bench.rs index b355f5568..757e9a3b7 100644 --- a/core/examples/http_bench.rs +++ b/core/examples/http_bench.rs @@ -111,10 +111,7 @@ 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>, -) -> (bool, Box<Op>) { +fn dispatch(control: &[u8], zero_copy_buf: Option<PinnedBuf>) -> Op { let record = Record::from(control); let is_sync = record.promise_id == 0; let http_bench_op = match record.op_id { @@ -147,7 +144,7 @@ fn dispatch( let mut record_a = record.clone(); let mut record_b = record.clone(); - let op = Box::new( + let fut = Box::new( http_bench_op .and_then(move |result| { record_a.result = result; @@ -161,7 +158,12 @@ fn dispatch( Ok(record.into()) }), ); - (is_sync, op) + + if is_sync { + Op::Sync(fut.wait().unwrap()) + } else { + Op::Async(fut) + } } fn main() { |