Crates.io | concurrent-round-robin |
lib.rs | concurrent-round-robin |
version | 0.1.0 |
source | src |
created_at | 2022-02-15 03:56:29.538826 |
updated_at | 2022-02-15 03:56:29.538826 |
description | A concurrent wrr implementation for rust |
homepage | |
repository | https://github.com/blazood/concurrent-round-robin |
max_upload_size | |
id | 532535 |
size | 6,917 |
A concurrent wrr implementation for rust
[dependencies]
concurrent-round-robin="0.1"
use concurrent_round_robin::WeightedRoundRobinSelector;
fn main() {
let balancer = Arc::new(WeightedRoundRobinSelector::new(
vec![("1", 1), ("2", 2)]
));
for _i in 0..100 {
let arc = balancer.clone();
std::thread::spawn(move || {
println!("{}", arc.select().unwrap().value());
});
}
}