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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 ~Worker() override; | 112 ~Worker() override; |
113 void Run() override; | 113 void Run() override; |
114 bool IsProcessingMessages() override; | 114 bool IsProcessingMessages() override; |
115 | 115 |
116 private: | 116 private: |
117 SignalThread* parent_; | 117 SignalThread* parent_; |
118 | 118 |
119 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Worker); | 119 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Worker); |
120 }; | 120 }; |
121 | 121 |
122 class SCOPED_LOCKABLE EnterExit { | 122 class RTC_SCOPED_LOCKABLE EnterExit { |
123 public: | 123 public: |
124 explicit EnterExit(SignalThread* t) EXCLUSIVE_LOCK_FUNCTION(t->cs_) | 124 explicit EnterExit(SignalThread* t) RTC_EXCLUSIVE_LOCK_FUNCTION(t->cs_) |
125 : t_(t) { | 125 : t_(t) { |
126 t_->cs_.Enter(); | 126 t_->cs_.Enter(); |
127 // If refcount_ is zero then the object has already been deleted and we | 127 // If refcount_ is zero then the object has already been deleted and we |
128 // will be double-deleting it in ~EnterExit()! (shouldn't happen) | 128 // will be double-deleting it in ~EnterExit()! (shouldn't happen) |
129 RTC_DCHECK_NE(0, t_->refcount_); | 129 RTC_DCHECK_NE(0, t_->refcount_); |
130 ++t_->refcount_; | 130 ++t_->refcount_; |
131 } | 131 } |
132 ~EnterExit() UNLOCK_FUNCTION() { | 132 ~EnterExit() RTC_UNLOCK_FUNCTION() { |
133 bool d = (0 == --t_->refcount_); | 133 bool d = (0 == --t_->refcount_); |
134 t_->cs_.Leave(); | 134 t_->cs_.Leave(); |
135 if (d) | 135 if (d) |
136 delete t_; | 136 delete t_; |
137 } | 137 } |
138 | 138 |
139 private: | 139 private: |
140 SignalThread* t_; | 140 SignalThread* t_; |
141 | 141 |
142 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EnterExit); | 142 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EnterExit); |
143 }; | 143 }; |
144 | 144 |
145 void Run(); | 145 void Run(); |
146 void OnMainThreadDestroyed(); | 146 void OnMainThreadDestroyed(); |
147 | 147 |
148 Thread* main_; | 148 Thread* main_; |
149 Worker worker_; | 149 Worker worker_; |
150 CriticalSection cs_; | 150 CriticalSection cs_; |
151 State state_; | 151 State state_; |
152 int refcount_; | 152 int refcount_; |
153 | 153 |
154 RTC_DISALLOW_COPY_AND_ASSIGN(SignalThread); | 154 RTC_DISALLOW_COPY_AND_ASSIGN(SignalThread); |
155 }; | 155 }; |
156 | 156 |
157 /////////////////////////////////////////////////////////////////////////////// | 157 /////////////////////////////////////////////////////////////////////////////// |
158 | 158 |
159 } // namespace rtc | 159 } // namespace rtc |
160 | 160 |
161 #endif // WEBRTC_RTC_BASE_SIGNALTHREAD_H_ | 161 #endif // WEBRTC_RTC_BASE_SIGNALTHREAD_H_ |
OLD | NEW |