You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to #309 we should add a method to Future that delays execution for a Duration. This method should be marked as "unstable".
This is useful in some cases where you want to define a Future that has a delay, rather than combining task::sleep with an async block and another future.
Examples
use async_std::future;let a = future::ready(1).delay(Duration::from_millis(200));let b = future::ready(2).delay(Duration::from_millis(100));let c = future::ready(3).delay(Duration::from_millis(300));dbg!(future::join!(a, b, c).await);
This is simlilar to this, but less nice to write:
let a = async{
task::sleep(Duration::from_millis(200).await;
future::ready(1).await};let b = async{
task::sleep(Duration::from_millis(100).await;
future::ready(2).await};let c = async{
task::sleep(Duration::from_millis(300).await;
future::ready(3).await};dbg!(future::join!(a, b, c).await);
The text was updated successfully, but these errors were encountered:
Similar to #309 we should add a method to
Future
that delays execution for aDuration
. This method should be marked as "unstable".This is useful in some cases where you want to define a
Future
that has a delay, rather than combiningtask::sleep
with an async block and another future.Examples
This is simlilar to this, but less nice to write:
The text was updated successfully, but these errors were encountered: