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

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

Issue 1619153003: CriticalSection: Use types+methods from base/platform_thread*.*. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 months 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
« no previous file with comments | « no previous file | webrtc/base/criticalsection.cc » ('j') | webrtc/base/criticalsection.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #ifndef WEBRTC_BASE_CRITICALSECTION_H_ 11 #ifndef WEBRTC_BASE_CRITICALSECTION_H_
12 #define WEBRTC_BASE_CRITICALSECTION_H_ 12 #define WEBRTC_BASE_CRITICALSECTION_H_
13 13
14 #include "webrtc/base/atomicops.h" 14 #include "webrtc/base/atomicops.h"
15 #include "webrtc/base/constructormagic.h" 15 #include "webrtc/base/constructormagic.h"
16 #include "webrtc/base/thread_annotations.h" 16 #include "webrtc/base/thread_annotations.h"
17 #include "webrtc/base/platform_thread_types.h"
17 18
18 #if defined(WEBRTC_WIN) 19 #if defined(WEBRTC_WIN)
19 // Include winsock2.h before including <windows.h> to maintain consistency with 20 // Include winsock2.h before including <windows.h> to maintain consistency with
20 // win32.h. We can't include win32.h directly here since it pulls in 21 // win32.h. We can't include win32.h directly here since it pulls in
21 // headers such as basictypes.h which causes problems in Chromium where webrtc 22 // headers such as basictypes.h which causes problems in Chromium where webrtc
22 // exists as two separate projects, webrtc and libjingle. 23 // exists as two separate projects, webrtc and libjingle.
23 #include <winsock2.h> 24 #include <winsock2.h>
24 #include <windows.h> 25 #include <windows.h>
25 #include <sal.h> // must come after windows headers. 26 #include <sal.h> // must come after windows headers.
26 #endif // defined(WEBRTC_WIN) 27 #endif // defined(WEBRTC_WIN)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Number of times the lock has been locked + number of threads waiting. 74 // Number of times the lock has been locked + number of threads waiting.
74 // TODO(tommi): We could use this number and subtract the recursion count 75 // TODO(tommi): We could use this number and subtract the recursion count
75 // to find places where we have multiple threads contending on the same lock. 76 // to find places where we have multiple threads contending on the same lock.
76 mutable volatile int lock_queue_; 77 mutable volatile int lock_queue_;
77 // |recursion_| represents the recursion count + 1 for the thread that owns 78 // |recursion_| represents the recursion count + 1 for the thread that owns
78 // the lock. Only modified by the thread that owns the lock. 79 // the lock. Only modified by the thread that owns the lock.
79 mutable int recursion_; 80 mutable int recursion_;
80 // Used to signal a single waiting thread when the lock becomes available. 81 // Used to signal a single waiting thread when the lock becomes available.
81 mutable dispatch_semaphore_t semaphore_; 82 mutable dispatch_semaphore_t semaphore_;
82 // The thread that currently holds the lock. Required to handle recursion. 83 // The thread that currently holds the lock. Required to handle recursion.
83 mutable pthread_t owning_thread_; 84 mutable PlatformThreadRef owning_thread_;
84 #else 85 #else
85 mutable pthread_mutex_t mutex_; 86 mutable pthread_mutex_t mutex_;
86 #endif 87 #endif
87 CS_DEBUG_CODE(mutable pthread_t thread_); 88 CS_DEBUG_CODE(mutable PlatformThreadRef thread_);
88 CS_DEBUG_CODE(mutable int recursion_count_); 89 CS_DEBUG_CODE(mutable int recursion_count_);
89 #endif 90 #endif
90 }; 91 };
91 92
92 // CritScope, for serializing execution through a scope. 93 // CritScope, for serializing execution through a scope.
93 class SCOPED_LOCKABLE CritScope { 94 class SCOPED_LOCKABLE CritScope {
94 public: 95 public:
95 explicit CritScope(const CriticalSection* cs) EXCLUSIVE_LOCK_FUNCTION(cs); 96 explicit CritScope(const CriticalSection* cs) EXCLUSIVE_LOCK_FUNCTION(cs);
96 ~CritScope() UNLOCK_FUNCTION(); 97 ~CritScope() UNLOCK_FUNCTION();
97 private: 98 private:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock); 145 explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock);
145 ~GlobalLockScope() UNLOCK_FUNCTION(); 146 ~GlobalLockScope() UNLOCK_FUNCTION();
146 private: 147 private:
147 GlobalLockPod* const lock_; 148 GlobalLockPod* const lock_;
148 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope); 149 RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope);
149 }; 150 };
150 151
151 } // namespace rtc 152 } // namespace rtc
152 153
153 #endif // WEBRTC_BASE_CRITICALSECTION_H_ 154 #endif // WEBRTC_BASE_CRITICALSECTION_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/criticalsection.cc » ('j') | webrtc/base/criticalsection.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698