4 个版本

使用旧的 Rust 2015

0.1.3 2016年11月28日
0.1.2 2016年11月28日
0.1.1 2016年11月28日
0.1.0 2016年11月28日

#18 in #10

Apache-2.0

6KB

rust-throttler

Rust 的简单节流器。

Crate Version Build Status Documentation

目前它只有一个非常简单且易于使用的节流器结构体,但将来还会添加更复杂的版本。

示例

以下示例创建了一个每秒允许执行4个操作的节流器,并使用它打印时间10次。

use throttler::simple::SimpleThrottler;
use std::time::{Duration, Instant};

let mut t = SimpleThrottler::new(4, Duration::new(1, 0));

for i in 0..10 {
    t.wait();
    println!("{} {:?}", i, Instant::now());
}

贡献

请随意贡献您想要的任何内容。


lib.rs:

一个简单的节流器库。

示例

以下示例创建了一个每秒允许执行4个操作的节流器,并使用它打印时间10次。

use throttler::simple::SimpleThrottler;
use std::time::{Duration, Instant};

let mut t = SimpleThrottler::new(4, Duration::new(1, 0));

for i in 0..10 {
    t.wait();
    println!("{} {:?}", i, Instant::now());
}

无运行时依赖