@@ -155,6 +155,33 @@ class GMessageManager : public GMessageObject,
155155 CGRAPH_FUNCTION_END
156156 }
157157
158+ /* *
159+ * 根据传入的topic,输入智能指针类型的信息
160+ * @tparam TImpl
161+ * @param topic
162+ * @param value
163+ * @param strategy
164+ * @return
165+ */
166+ template <typename TImpl,
167+ c_enable_if_t <std::is_base_of<T, TImpl>::value, int > = 0 >
168+ CStatus sendTopicValue (const std::string& topic,
169+ std::unique_ptr<TImpl>& value,
170+ GMessagePushStrategy strategy) {
171+ CGRAPH_FUNCTION_BEGIN
172+ auto innerTopic = SEND_RECV_PREFIX + topic;
173+ auto result = send_recv_message_map_.find (innerTopic);
174+ if (result == send_recv_message_map_.end ()) {
175+ CGRAPH_RETURN_ERROR_STATUS (" no find [" + topic + " ] topic" );
176+ }
177+
178+ auto message = static_cast <GMessagePtr<T> >(result->second );
179+ CGRAPH_ASSERT_NOT_NULL (message);
180+
181+ message->send (value, strategy);
182+ CGRAPH_FUNCTION_END
183+ }
184+
158185 /* *
159186 * 绑定对应的topic信息,并且获取 conn_id 信息
160187 * @tparam TImpl
@@ -165,10 +192,10 @@ class GMessageManager : public GMessageObject,
165192 template <typename TImpl,
166193 c_enable_if_t <std::is_base_of<T, TImpl>::value, int > = 0 >
167194 CIndex bindTopic (const std::string& topic, CUint size) {
168- CGRAPH_LOCK_GUARD lock (bind_mutex_);
169195 auto innerTopic = PUB_SUB_PREFIX + topic;
170196 auto message = UAllocator::safeMallocTemplateCObject<GMessage<TImpl>, CUint>(size);
171197
198+ CGRAPH_LOCK_GUARD lock (bind_mutex_);
172199 CIndex connId = (++cur_conn_id_);
173200 auto result = pub_sub_message_map_.find (innerTopic);
174201 if (result != pub_sub_message_map_.end ()) {
0 commit comments