Last active
July 28, 2020 00:31
-
-
Save JohnMurray/9f40d1dce4a46ad51fa21d1002f26626 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
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