Something went wrong. Try again.
A small throttle utility that collects items and provides a way to handle them after a configured delay. crates.io/crates/simple-throttle
Something went wrong. Try again.
Files
Verified signature Signed by tijarist.xyz SHA256:fAof1PtBPUupszJEQ+bbFRGwypEFoMt2mLfD49AWn5w Click to copy SHA
Verified signature Signed by tijarist.xyz SHA256:fAof1PtBPUupszJEQ+bbFRGwypEFoMt2mLfD49AWn5w Click to copy SHA
- Rust 100%
README.md
Simple Throttle #
A small throttle utility that collects items and invokes a handler after a configured delay.
Works in both blocking and asynchronous contexts, enable the tokio feature for async support.
Example #
use simple_throttle::Throttle;
use std::time::Duration;
#[tokio::main]
async fn main() {
let mut throttle: Throttle<u32> = Throttle::new(Duration::from_secs(1));
throttle.push(1);
throttle.wait_ready().await;
throttle.trigger(|mut queue| async move {
while let Some(item) = queue.pop_front() {
println!("Item: {}", item);
}
}).await;
}