MCPcopy Create free account
hub / github.com/Tencent/mars / SingletonMessage

Function SingletonMessage

mars/comm/messagequeue/message_queue.cc:358–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358MessagePost_t SingletonMessage(bool _replace, const MessageHandler_t& _handlerid, const Message& _message, const MessageTiming& _timing) {
359 ScopedLock lock(sg_messagequeue_map_mutex);
360 const MessageQueue_t& id = _handlerid.queue;
361
362 std::map<MessageQueue_t, MessageQueueContent>::iterator pos = sg_messagequeue_map.find(id);
363 if (sg_messagequeue_map.end() == pos) return KNullPost;
364
365 MessageQueueContent& content = pos->second;
366
367 MessagePost_t post_id;
368
369 for (std::list<MessageWrapper*>::iterator it = content.lst_message.begin(); it != content.lst_message.end(); ++it) {
370 if ((*it)->postid.reg == _handlerid && (*it)->message == _message) {
371 if (_replace) {
372 post_id = (*it)->postid;
373 delete(*it);
374 content.lst_message.erase(it);
375 break;
376 } else {
377 return (*it)->postid;
378 }
379 }
380 }
381
382 if(content.lst_message.size() >= MAX_MQ_SIZE) {
383 xwarn2(TSF"%_", DumpMessage(content.lst_message));
384 ASSERT2(false, "Over MAX_MQ_SIZE");
385 return KNullPost;
386 }
387
388 MessageWrapper* messagewrapper = new MessageWrapper(_handlerid, _message, _timing, 0 != post_id.seq ? post_id.seq : __MakeSeq());
389 content.lst_message.push_back(messagewrapper);
390 content.breaker->Notify(lock);
391 return messagewrapper->postid;
392}
393
394MessagePost_t BroadcastMessage(const MessageQueue_t& _messagequeueid, const Message& _message, const MessageTiming& _timing) {
395 ScopedLock lock(sg_messagequeue_map_mutex);

Callers 2

SaveTaskMethod · 0.85
TESTFunction · 0.85

Calls 9

DumpMessageFunction · 0.85
__MakeSeqFunction · 0.85
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
NotifyMethod · 0.45

Tested by 1

TESTFunction · 0.68