Last active
July 26, 2020 01:48
-
-
Save JohnMurray/23e715af5f0d5be1c6b006423bc92a98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<BehaviorType T> | |
class RoundRobinRouter | |
: public Actor | |
, public T | |
{ | |
const std::vector<actor_ref<T>> m_children; | |
std::vector<actor_ref<T>>::iterator m_it; | |
public: | |
RoundRobinRouter(std::vector<actor_ref<T>> const& actors) | |
: m_children(actors), m_it(children.begin()) {} | |
template<BehaviorReceives<T> Msg> | |
void receive(Msg const& msg) { | |
(*m_it).send(msg); | |
if (++m_it == m_children.end()) { | |
m_it = m_children.begin(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment