| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void MessageQueueManager::ClearInternal(MessageHandler *handler) { | 106 void MessageQueueManager::ClearInternal(MessageHandler *handler) { |
| 107 #if CS_DEBUG_CHECKS // CurrentThreadIsOwner returns true by default. | 107 #if CS_DEBUG_CHECKS // CurrentThreadIsOwner returns true by default. |
| 108 ASSERT(!crit_.CurrentThreadIsOwner()); // See note above. | 108 ASSERT(!crit_.CurrentThreadIsOwner()); // See note above. |
| 109 #endif | 109 #endif |
| 110 CritScope cs(&crit_); | 110 CritScope cs(&crit_); |
| 111 std::vector<MessageQueue *>::iterator iter; | 111 std::vector<MessageQueue *>::iterator iter; |
| 112 for (iter = message_queues_.begin(); iter != message_queues_.end(); iter++) | 112 for (iter = message_queues_.begin(); iter != message_queues_.end(); iter++) |
| 113 (*iter)->Clear(handler); | 113 (*iter)->Clear(handler); |
| 114 } | 114 } |
| 115 | 115 |
| 116 class NoOpMessageHandler : public MessageHandler { |
| 117 public: |
| 118 void OnMessage(Message* msg) override {} |
| 119 }; |
| 120 |
| 121 void MessageQueueManager::WakeAllMessageQueues() { |
| 122 if (!instance_) { |
| 123 return; |
| 124 } |
| 125 return Instance()->WakeAllMessageQueuesInternal(); |
| 126 } |
| 127 void MessageQueueManager::WakeAllMessageQueuesInternal() { |
| 128 #if CS_DEBUG_CHECKS // CurrentThreadIsOwner returns true by default. |
| 129 ASSERT(!crit_.CurrentThreadIsOwner()); // See note above. |
| 130 #endif |
| 131 CritScope cs(&crit_); |
| 132 for (MessageQueue* queue : message_queues_) { |
| 133 queue->Post(new NoOpMessageHandler(), 0); |
| 134 } |
| 135 } |
| 136 |
| 116 //------------------------------------------------------------------ | 137 //------------------------------------------------------------------ |
| 117 // MessageQueue | 138 // MessageQueue |
| 118 | 139 |
| 119 MessageQueue::MessageQueue(SocketServer* ss, bool init_queue) | 140 MessageQueue::MessageQueue(SocketServer* ss, bool init_queue) |
| 120 : fStop_(false), fPeekKeep_(false), | 141 : fStop_(false), fPeekKeep_(false), |
| 121 dmsgq_next_num_(0), fInitialized_(false), fDestroyed_(false), ss_(ss) { | 142 dmsgq_next_num_(0), fInitialized_(false), fDestroyed_(false), ss_(ss) { |
| 122 if (!ss_) { | 143 if (!ss_) { |
| 123 // Currently, MessageQueue holds a socket server, and is the base class for | 144 // Currently, MessageQueue holds a socket server, and is the base class for |
| 124 // Thread. It seems like it makes more sense for Thread to hold the socket | 145 // Thread. It seems like it makes more sense for Thread to hold the socket |
| 125 // server, and provide it to the MessageQueue, since the Thread controls | 146 // server, and provide it to the MessageQueue, since the Thread controls |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 469 } |
| 449 dmsgq_.container().erase(new_end, dmsgq_.container().end()); | 470 dmsgq_.container().erase(new_end, dmsgq_.container().end()); |
| 450 dmsgq_.reheap(); | 471 dmsgq_.reheap(); |
| 451 } | 472 } |
| 452 | 473 |
| 453 void MessageQueue::Dispatch(Message *pmsg) { | 474 void MessageQueue::Dispatch(Message *pmsg) { |
| 454 pmsg->phandler->OnMessage(pmsg); | 475 pmsg->phandler->OnMessage(pmsg); |
| 455 } | 476 } |
| 456 | 477 |
| 457 } // namespace rtc | 478 } // namespace rtc |
| OLD | NEW |