17 #ifndef CYBER_TRANSPORT_DISPATCHER_SHM_DISPATCHER_H_ 18 #define CYBER_TRANSPORT_DISPATCHER_SHM_DISPATCHER_H_ 24 #include <unordered_map> 54 template <
typename MessageT>
58 template <
typename MessageT>
60 const RoleAttributes& opposite_attr,
64 void AddSegment(
const RoleAttributes& self_attr);
65 void ReadMessage(uint64_t channel_id, uint32_t block_index);
66 void OnMessage(uint64_t channel_id,
const std::shared_ptr<ReadableBlock>& rb,
73 std::unordered_map<uint64_t, uint32_t> previous_indexes_;
81 template <
typename MessageT>
85 auto listener_adapter = [listener](
const std::shared_ptr<ReadableBlock>& rb,
87 auto msg = std::make_shared<MessageT>();
89 rb->buf, static_cast<int>(rb->block->msg_size()), msg.get()));
90 listener(msg, msg_info);
93 Dispatcher::AddListener<ReadableBlock>(self_attr, listener_adapter);
94 AddSegment(self_attr);
97 template <
typename MessageT>
99 const RoleAttributes& opposite_attr,
102 auto listener_adapter = [listener](
const std::shared_ptr<ReadableBlock>& rb,
104 auto msg = std::make_shared<MessageT>();
106 rb->buf, static_cast<int>(rb->block->msg_size()), msg.get()));
107 listener(msg, msg_info);
110 Dispatcher::AddListener<ReadableBlock>(self_attr, opposite_attr,
112 AddSegment(self_attr);
119 #endif // CYBER_TRANSPORT_DISPATCHER_SHM_DISPATCHER_H_ void AddListener(const RoleAttributes &self_attr, const MessageListener< MessageT > &listener)
Definition: shm_dispatcher.h:82
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: rw_lock_guard.h:48
Definition: atomic_rw_lock.h:36
#define RETURN_IF(condition)
Definition: log.h:106
std::enable_if< HasParseFromArray< T >::value, bool >::type ParseFromArray(const void *data, int size, T *message)
Definition: message_traits.h:145
Definition: notifier_base.h:31
std::unordered_map< uint64_t, SegmentPtr > SegmentContainer
Definition: shm_dispatcher.h:48
Definition: shm_dispatcher.h:45
Definition: dispatcher.h:54
#define DECLARE_SINGLETON(classname)
Definition: macros.h:52
Definition: rw_lock_guard.h:35
Definition: message_info.h:30
std::function< void(const std::shared_ptr< MessageT > &, const MessageInfo &)> MessageListener
Definition: dispatcher.h:52