[−][src]Macro join::try_join_async_spawn
Use to spawn ::tokio::spawn
per each step of each branch.
#![recursion_limit="512"] extern crate join; extern crate futures; extern crate tokio; extern crate futures_timer; use join::try_join_async_spawn; use futures::future::ok; use futures_timer::Delay; use std::time::Duration; #[tokio::main] async fn main() { let product = try_join_async_spawn! { ok::<_,u8>(2u16) |> |v| Ok::<_,u8>(v.unwrap() + 2u16) => |v| async move { println!("Hello from parallel world!"); Delay::new(Duration::from_secs(1)).await; println!("I'm done."); Ok(v) }, ok::<_,u8>(3u16) => |v| async move { println!("Hello from parallel world again!"); Delay::new(Duration::from_secs(2)).await; println!("Me too."); Ok(v) }, ok::<_,u8>(4u16), map => |a, b, c| a * b * c }.await.unwrap(); assert_eq!(product, 48); }