use std::sync::Arc;
use crate::Rank;
use crate::jiffy::Jiffies;
use crate::random::Randomizer;
use crate::topology::Topology;
pub(crate) struct Latency {
topology: Arc<Topology>,
randomizer: Randomizer,
}
impl Latency {
pub(crate) fn new(randomizer: Randomizer, topology: Arc<Topology>) -> Self {
Self {
randomizer,
topology,
}
}
pub(crate) fn random_latency(&mut self, source: Rank, target: Rank) -> Jiffies {
let distribution = self.topology.get_distribution(source, target);
Jiffies(self.randomizer.random_usize(distribution))
}
}