| 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_SIGNALTHREAD_H_ | 11 #ifndef WEBRTC_BASE_SIGNALTHREAD_H_ |
| 12 #define WEBRTC_BASE_SIGNALTHREAD_H_ | 12 #define WEBRTC_BASE_SIGNALTHREAD_H_ |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
| 17 #include "webrtc/base/nullsocketserver.h" | 18 #include "webrtc/base/nullsocketserver.h" |
| 18 #include "webrtc/base/sigslot.h" | 19 #include "webrtc/base/sigslot.h" |
| 19 #include "webrtc/base/thread.h" | 20 #include "webrtc/base/thread.h" |
| 20 | 21 |
| 21 namespace rtc { | 22 namespace rtc { |
| 22 | 23 |
| 23 /////////////////////////////////////////////////////////////////////////////// | 24 /////////////////////////////////////////////////////////////////////////////// |
| 24 // SignalThread - Base class for worker threads. The main thread should call | 25 // SignalThread - Base class for worker threads. The main thread should call |
| 25 // Start() to begin work, and then follow one of these models: | 26 // Start() to begin work, and then follow one of these models: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Worker); | 118 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Worker); |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 class SCOPED_LOCKABLE EnterExit { | 121 class SCOPED_LOCKABLE EnterExit { |
| 121 public: | 122 public: |
| 122 explicit EnterExit(SignalThread* t) EXCLUSIVE_LOCK_FUNCTION(t->cs_) | 123 explicit EnterExit(SignalThread* t) EXCLUSIVE_LOCK_FUNCTION(t->cs_) |
| 123 : t_(t) { | 124 : t_(t) { |
| 124 t_->cs_.Enter(); | 125 t_->cs_.Enter(); |
| 125 // If refcount_ is zero then the object has already been deleted and we | 126 // If refcount_ is zero then the object has already been deleted and we |
| 126 // will be double-deleting it in ~EnterExit()! (shouldn't happen) | 127 // will be double-deleting it in ~EnterExit()! (shouldn't happen) |
| 127 ASSERT(t_->refcount_ != 0); | 128 RTC_DCHECK(t_->refcount_ != 0); |
| 128 ++t_->refcount_; | 129 ++t_->refcount_; |
| 129 } | 130 } |
| 130 ~EnterExit() UNLOCK_FUNCTION() { | 131 ~EnterExit() UNLOCK_FUNCTION() { |
| 131 bool d = (0 == --t_->refcount_); | 132 bool d = (0 == --t_->refcount_); |
| 132 t_->cs_.Leave(); | 133 t_->cs_.Leave(); |
| 133 if (d) | 134 if (d) |
| 134 delete t_; | 135 delete t_; |
| 135 } | 136 } |
| 136 | 137 |
| 137 private: | 138 private: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 150 int refcount_; | 151 int refcount_; |
| 151 | 152 |
| 152 RTC_DISALLOW_COPY_AND_ASSIGN(SignalThread); | 153 RTC_DISALLOW_COPY_AND_ASSIGN(SignalThread); |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 /////////////////////////////////////////////////////////////////////////////// | 156 /////////////////////////////////////////////////////////////////////////////// |
| 156 | 157 |
| 157 } // namespace rtc | 158 } // namespace rtc |
| 158 | 159 |
| 159 #endif // WEBRTC_BASE_SIGNALTHREAD_H_ | 160 #endif // WEBRTC_BASE_SIGNALTHREAD_H_ |
| OLD | NEW |