From c171813e894f0759abb1b80413aa2a24dbad079b Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 1 May 2019 18:22:32 -0400 Subject: core: express op as enum (#2255) --- core/examples/http_bench.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'core/examples') 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 + Send; -fn dispatch( - control: &[u8], - zero_copy_buf: Option, -) -> (bool, Box) { +fn dispatch(control: &[u8], zero_copy_buf: Option) -> 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() { -- cgit v1.2.3