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 19 matching lines...) Expand all Loading... |
30 #include "webrtc/base/timeutils.h" | 30 #include "webrtc/base/timeutils.h" |
31 #include "webrtc/base/thread_annotations.h" | 31 #include "webrtc/base/thread_annotations.h" |
32 | 32 |
33 namespace rtc { | 33 namespace rtc { |
34 | 34 |
35 struct Message; | 35 struct Message; |
36 class MessageQueue; | 36 class MessageQueue; |
37 | 37 |
38 // MessageQueueManager does cleanup of of message queues | 38 // MessageQueueManager does cleanup of of message queues |
39 | 39 |
40 class MessageQueueManager { | 40 class MessageQueueManager : public MessageHandler { |
41 public: | 41 public: |
42 static void Add(MessageQueue *message_queue); | 42 static void Add(MessageQueue *message_queue); |
43 static void Remove(MessageQueue *message_queue); | 43 static void Remove(MessageQueue *message_queue); |
44 static void Clear(MessageHandler *handler); | 44 static void Clear(MessageHandler *handler); |
45 | 45 |
46 // For testing purposes, we expose whether or not the MessageQueueManager | 46 // For testing purposes, we expose whether or not the MessageQueueManager |
47 // instance has been initialized. It has no other use relative to the rest of | 47 // instance has been initialized. It has no other use relative to the rest of |
48 // the functions of this class, which auto-initialize the underlying | 48 // the functions of this class, which auto-initialize the underlying |
49 // MessageQueueManager instance when necessary. | 49 // MessageQueueManager instance when necessary. |
50 static bool IsInitialized(); | 50 static bool IsInitialized(); |
51 | 51 |
52 // Mainly for testing purposes, for use with a simulated clock. | 52 // Mainly for testing purposes, for use with a simulated clock. |
53 // Ensures that all message queues have processed delayed messages | 53 // Posts a no-op event on all message queues so they will wake from the |
54 // up until the current point in time. | 54 // socket server select() and process messages again. |
55 static void ProcessAllMessageQueues(); | 55 static void WakeAllMessageQueues(); |
56 | 56 |
57 private: | 57 private: |
58 static MessageQueueManager* Instance(); | 58 static MessageQueueManager* Instance(); |
59 | 59 |
60 MessageQueueManager(); | 60 MessageQueueManager(); |
61 ~MessageQueueManager(); | 61 ~MessageQueueManager() override; |
62 | 62 |
63 void AddInternal(MessageQueue *message_queue); | 63 void AddInternal(MessageQueue *message_queue); |
64 void RemoveInternal(MessageQueue *message_queue); | 64 void RemoveInternal(MessageQueue *message_queue); |
65 void ClearInternal(MessageHandler *handler); | 65 void ClearInternal(MessageHandler *handler); |
66 void ProcessAllMessageQueuesInternal(); | 66 void WakeAllMessageQueuesInternal(); |
| 67 void OnMessage(Message* pmsg) override; |
67 | 68 |
68 static MessageQueueManager* instance_; | 69 static MessageQueueManager* instance_; |
69 // This list contains all live MessageQueues. | 70 // This list contains all live MessageQueues. |
70 std::vector<MessageQueue *> message_queues_; | 71 std::vector<MessageQueue *> message_queues_; |
71 CriticalSection crit_; | 72 CriticalSection crit_; |
72 }; | 73 }; |
73 | 74 |
74 // Derive from this for specialized data | 75 // Derive from this for specialized data |
75 // App manages lifetime, except when messages are purged | 76 // App manages lifetime, except when messages are purged |
76 | 77 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 // Used if SocketServer ownership lies with |this|. | 296 // Used if SocketServer ownership lies with |this|. |
296 std::unique_ptr<SocketServer> own_ss_; | 297 std::unique_ptr<SocketServer> own_ss_; |
297 SharedExclusiveLock ss_lock_; | 298 SharedExclusiveLock ss_lock_; |
298 | 299 |
299 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); | 300 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MessageQueue); |
300 }; | 301 }; |
301 | 302 |
302 } // namespace rtc | 303 } // namespace rtc |
303 | 304 |
304 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ | 305 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ |
OLD | NEW |