Skip to content

Instantly share code, notes, and snippets.

@JohnMurray
Last active Jul 28, 2020
Embed
What would you like to do?
class Actor {
std::deque<std::function<void()>> m_messages;
public:
virtual ~Actor() = default;
void enqueue(std::function<void()> const& func) {
m_messages.push_back(func);
}
void process_message() {
if (m_messages.begin() != m_messages.end()) {
(*m_messages.begin())();
m_messages.pop_front();
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment