10 #include <message_bus.hpp>
11 #include <ST_util/pool_allocator_256.hpp>
20 std::vector<subscriber *> *temp = &subscribers[arg->msg_name];
21 uint64_t size = temp->size();
27 if (size != 0) [[likely]] {
28 temp->operator[](0)->push_message(arg);
29 for (uint64_t i = 1; i < size; ++i) {
30 temp->operator[](i)->push_message(arg->
make_copy());
35 static bool singleton_initialized =
false;
42 if (singleton_initialized) {
43 throw std::runtime_error(
"The message bus cannot be initialized more than once!");
45 singleton_initialized =
true;
56 singleton_initialized =
false;
72 subscribers[msg].emplace_back(sub);
void subscribe(uint8_t msg, subscriber *sub)
void send_msg(message *msg)
A message object passed around in the message bus. Holds anything created with make_data<>().
message * make_copy() const
This class handles a small queue for messages.