Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: webrtc/base/criticalsection.h

Issue 1420043008: Create rtc::AtomicInt POD struct. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: ctor version, let's pray they are put in .data or .bss Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 CriticalSection* const cs_; 95 CriticalSection* const cs_;
96 const bool locked_; 96 const bool locked_;
97 CS_DEBUG_CODE(mutable bool lock_was_called_); 97 CS_DEBUG_CODE(mutable bool lock_was_called_);
98 RTC_DISALLOW_COPY_AND_ASSIGN(TryCritScope); 98 RTC_DISALLOW_COPY_AND_ASSIGN(TryCritScope);
99 }; 99 };
100 100
101 // A POD lock used to protect global variables. Do NOT use for other purposes. 101 // A POD lock used to protect global variables. Do NOT use for other purposes.
102 // No custom constructor or private data member should be added. 102 // No custom constructor or private data member should be added.
103 class LOCKABLE GlobalLockPod { 103 class LOCKABLE GlobalLockPod {
104 public: 104 public:
105 GlobalLockPod() : lock_acquired(0) {}
105 void Lock() EXCLUSIVE_LOCK_FUNCTION(); 106 void Lock() EXCLUSIVE_LOCK_FUNCTION();
106 107
107 void Unlock() UNLOCK_FUNCTION(); 108 void Unlock() UNLOCK_FUNCTION();
108 109
109 volatile int lock_acquired; 110 AtomicInt lock_acquired;
110 }; 111 };
111 112
112 class GlobalLock : public GlobalLockPod { 113 class GlobalLock : public GlobalLockPod {
113 public: 114 public:
114 GlobalLock(); 115 GlobalLock();
115 }; 116 };
116 117
117 // GlobalLockScope, for serializing execution through a scope. 118 // GlobalLockScope, for serializing execution through a scope.
118 class SCOPED_LOCKABLE GlobalLockScope { 119 class SCOPED_LOCKABLE GlobalLockScope {
119 public: 120 public:
120 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock); 121 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock);
121 ~GlobalLockScope() UNLOCK_FUNCTION(); 122 ~GlobalLockScope() UNLOCK_FUNCTION();
122 private: 123 private:
123 GlobalLockPod* const lock_; 124 GlobalLockPod* const lock_;
124 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope); 125 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope);
125 }; 126 };
126 127
127 } // namespace rtc 128 } // namespace rtc
128 129
129 #endif // WEBRTC_BASE_CRITICALSECTION_H_ 130 #endif // WEBRTC_BASE_CRITICALSECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698