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 |
11 #ifndef WEBRTC_BASE_MESSAGEQUEUE_H_ | 11 #ifndef WEBRTC_BASE_MESSAGEQUEUE_H_ |
12 #define WEBRTC_BASE_MESSAGEQUEUE_H_ | 12 #define WEBRTC_BASE_MESSAGEQUEUE_H_ |
13 | 13 |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
16 #include <algorithm> | 16 #include <algorithm> |
17 #include <list> | 17 #include <list> |
| 18 #include <memory> |
18 #include <queue> | 19 #include <queue> |
19 #include <vector> | 20 #include <vector> |
20 | 21 |
21 #include "webrtc/base/basictypes.h" | 22 #include "webrtc/base/basictypes.h" |
22 #include "webrtc/base/constructormagic.h" | 23 #include "webrtc/base/constructormagic.h" |
23 #include "webrtc/base/criticalsection.h" | 24 #include "webrtc/base/criticalsection.h" |
24 #include "webrtc/base/messagehandler.h" | 25 #include "webrtc/base/messagehandler.h" |
25 #include "webrtc/base/scoped_ptr.h" | |
26 #include "webrtc/base/scoped_ref_ptr.h" | 26 #include "webrtc/base/scoped_ref_ptr.h" |
27 #include "webrtc/base/sharedexclusivelock.h" | 27 #include "webrtc/base/sharedexclusivelock.h" |
28 #include "webrtc/base/sigslot.h" | 28 #include "webrtc/base/sigslot.h" |
29 #include "webrtc/base/socketserver.h" | 29 #include "webrtc/base/socketserver.h" |
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; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 T& data() { return data_; } | 82 T& data() { return data_; } |
83 private: | 83 private: |
84 T data_; | 84 T data_; |
85 }; | 85 }; |
86 | 86 |
87 // Like TypedMessageData, but for pointers that require a delete. | 87 // Like TypedMessageData, but for pointers that require a delete. |
88 template <class T> | 88 template <class T> |
89 class ScopedMessageData : public MessageData { | 89 class ScopedMessageData : public MessageData { |
90 public: | 90 public: |
91 explicit ScopedMessageData(T* data) : data_(data) { } | 91 explicit ScopedMessageData(T* data) : data_(data) { } |
92 const scoped_ptr<T>& data() const { return data_; } | 92 const std::unique_ptr<T>& data() const { return data_; } |
93 scoped_ptr<T>& data() { return data_; } | 93 std::unique_ptr<T>& data() { return data_; } |
| 94 |
94 private: | 95 private: |
95 scoped_ptr<T> data_; | 96 std::unique_ptr<T> data_; |
96 }; | 97 }; |
97 | 98 |
98 // Like ScopedMessageData, but for reference counted pointers. | 99 // Like ScopedMessageData, but for reference counted pointers. |
99 template <class T> | 100 template <class T> |
100 class ScopedRefMessageData : public MessageData { | 101 class ScopedRefMessageData : public MessageData { |
101 public: | 102 public: |
102 explicit ScopedRefMessageData(T* data) : data_(data) { } | 103 explicit ScopedRefMessageData(T* data) : data_(data) { } |
103 const scoped_refptr<T>& data() const { return data_; } | 104 const scoped_refptr<T>& data() const { return data_; } |
104 scoped_refptr<T>& data() { return data_; } | 105 scoped_refptr<T>& data() { return data_; } |
105 private: | 106 private: |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 PriorityQueue dmsgq_ GUARDED_BY(crit_); | 272 PriorityQueue dmsgq_ GUARDED_BY(crit_); |
272 uint32_t dmsgq_next_num_ GUARDED_BY(crit_); | 273 uint32_t dmsgq_next_num_ GUARDED_BY(crit_); |
273 CriticalSection crit_; | 274 CriticalSection crit_; |
274 bool fInitialized_; | 275 bool fInitialized_; |
275 bool fDestroyed_; | 276 bool fDestroyed_; |
276 | 277 |
277 private: | 278 private: |
278 // The SocketServer is not owned by MessageQueue. | 279 // The SocketServer is not owned by MessageQueue. |
279 SocketServer* ss_ GUARDED_BY(ss_lock_); | 280 SocketServer* ss_ GUARDED_BY(ss_lock_); |
280 // If a server isn't supplied in the constructor, use this one. | 281 // If a server isn't supplied in the constructor, use this one. |
281 scoped_ptr<SocketServer> default_ss_; | 282 std::unique_ptr<SocketServer> default_ss_; |
282 SharedExclusiveLock ss_lock_; | 283 SharedExclusiveLock ss_lock_; |
283 | 284 |
284 RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue); | 285 RTC_DISALLOW_COPY_AND_ASSIGN(MessageQueue); |
285 }; | 286 }; |
286 | 287 |
287 } // namespace rtc | 288 } // namespace rtc |
288 | 289 |
289 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ | 290 #endif // WEBRTC_BASE_MESSAGEQUEUE_H_ |
OLD | NEW |