andrewjstone/rabble

Pass envelope vec as mut ref

Closed this issue · 1 comments

pub trait Process : Send {
    // ...
    fn handle(&mut self,
              msg: Msg<Self::Msg>,
              from: Pid,
              correlation_id: Option<CorrelationId>,
              envelopes: &mut Vec<Envelope<Self::Msg>>);
}

instead of

pub trait Process : Send {
    // ...
    fn handle(&mut self,
              msg: Msg<Self::Msg>,
              from: Pid,
              correlation_id: Option<CorrelationId>)
        -> &mut Vec<Envelope<Self::Msg>>;
}

And then let rabble manage the vec.

Excellent idea! This will result in less memory usage overall as now only one vec will need to be allocated for all processes. It shouldn't hinder testing at all either, as any test scheduler will now manage the vec rather than the executor.