20 #ifndef ANTKEEPER_EVENT_CHANNEL_HPP
21 #define ANTKEEPER_EVENT_CHANNEL_HPP
62 std::shared_ptr<subscriber_type> shared_subscriber = std::make_shared<subscriber_type>(std::move(
subscriber));
65 auto iterator = subscribers.insert(subscribers.end(), shared_subscriber);
68 return std::make_shared<subscription>
70 std::static_pointer_cast<void>(shared_subscriber),
71 [
this, iterator = std::move(iterator)]
73 this->subscribers.erase(iterator);
118 std::list<std::shared_ptr<subscriber_type>> subscribers;
Channel through which messages are published.
std::shared_ptr< subscription > subscribe(subscriber_type &&subscriber)
Subscribes a function object to messages published through this channel.
std::shared_ptr< subscription > subscribe(event::dispatcher &dispatcher)
Subscribes a message dispatcher to messages published through this channel.
T message_type
Message type.
subscriber< message_type > subscriber_type
Subscriber function object type.
Forwards messages from publishers to subscribers.
void dispatch(const T &message) const
Dispatches a message to subscribers of the message type.
Publishes messages to subscribers.
Collects messages from publishers to be dispatched to subscribers when desired.
void enqueue(const T &message)
Adds a message to the queue, to be distributed later.
Publish-subscribe messaging.
std::function< void(const T &)> subscriber
Subscriber function object type.