#round-robin #wrr #vec #move #spawn #weighted-round-robin-selector

concurrent-round-robin

A concurrent wrr implementation for rust

1 unstable release

0.1.0 Feb 15, 2022

#784 in Concurrency

MIT license

6KB
103 lines

concurrent-round-robin

A concurrent wrr implementation for rust

quick start

[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());
        });
    }
}

Dependencies

~2–7MB
~39K SLoC