Skip to main content

atomr_core/routing/
broadcast.rs

1//! Broadcast router.
2
3use crate::actor::ActorRef;
4
5pub struct BroadcastRouter<M: Send + Clone + 'static> {
6    routees: Vec<ActorRef<M>>,
7}
8
9impl<M: Send + Clone + 'static> BroadcastRouter<M> {
10    pub fn new(routees: Vec<ActorRef<M>>) -> Self {
11        Self { routees }
12    }
13
14    pub fn route(&self, msg: M) {
15        for r in &self.routees {
16            r.tell(msg.clone());
17        }
18    }
19}