Trait caminos_lib::traffic::Traffic[][src]

pub trait Traffic: Quantifiable + Debug {
    fn generate_message(
        &mut self,
        origin: usize,
        cycle: usize,
        topology: &Box<dyn Topology>,
        rng: &RefCell<StdRng>
    ) -> Result<Rc<Message>, TrafficError>;
fn probability_per_cycle(&self, server: usize) -> f32;
fn try_consume(
        &mut self,
        message: Rc<Message>,
        cycle: usize,
        topology: &Box<dyn Topology>,
        rng: &RefCell<StdRng>
    ) -> bool;
fn is_finished(&self) -> bool; fn should_generate(
        &self,
        server: usize,
        _cycle: usize,
        rng: &RefCell<StdRng>
    ) -> bool { ... } }
Expand description

A traffic to be offered to a network. Each server may generate and consume messages. Each should call should_generate every cycle unless it is unable to store more messages.

Required methods

Returns a new message following the indications of the traffic

Get its probability of generating per cycle

If the message was generated by the traffic updates itself and returns true

Indicates if the traffic is not going to generate any more messages.

Provided methods

Returns true if a server should generate a message this cycle

Implementors