2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-01-16 10:49:55 +00:00

remove throttle example

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
Yoshua Wuyts 2019-11-14 21:27:14 +01:00
parent 338273eb18
commit 1546448800
No known key found for this signature in database
GPG key ID: 24EA8164F96777ED

View file

@ -1,27 +0,0 @@
//! Spawns a timed task which gets throttled.
fn main() {
#[cfg(feature = "unstable")]
{
use async_std::prelude::*;
use async_std::task;
task::block_on(async {
use async_std::stream;
use std::time::Duration;
// emit value every 1 second
let s = stream::interval(Duration::from_secs(1)).enumerate();
// throttle for 2 seconds
let s = s.throttle(Duration::from_secs(2));
s.for_each(|(n, _)| {
dbg!(n);
})
.await;
// => 0 .. 1 .. 2 .. 3
// with a pause of 2 seconds between each print
})
}
}