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