#![ feature( duration_constants ) ]
#[ cfg(not( target_arch = "wasm32" )) ]
fn main()
{
use
{
async_runtime :: { * } ,
std :: { time::{ Duration, Instant }, thread::sleep } ,
futures :: { future::{ FutureExt, join_all } } ,
};
let program = async
{
let start = Instant::now();
let mut tasks = Vec::new();
for i in 0..8
{
let (fut, handle) = async move
{
sleep( Duration::SECOND );
println!( "Time elapsed at task {} end: {} second(s).", i, start.elapsed().as_secs() );
}.remote_handle();
rt::spawn( fut ).expect( "spawn task" );
tasks.push( handle );
}
join_all( tasks ).await;
};
rt::block_on( program );
}
#[ cfg( target_arch = "wasm32" ) ]
fn main(){}