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

Side by Side Diff: webrtc/system_wrappers/source/rw_lock_winxp_win.cc

Issue 1595983002: Rename RWLockGeneric to RWLockWinXP to more accurately reflect when it's used. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix missing include 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/system_wrappers/source/rw_lock_winxp_win.h"
12
13 namespace webrtc {
14
15 RWLockWinXP::RWLockWinXP() {}
16 RWLockWinXP::~RWLockWinXP() {}
17
18 void RWLockWinXP::AcquireLockExclusive() {
19 CriticalSectionScoped cs(&critical_section_);
20 if (writer_active_ || readers_active_ > 0) {
21 ++writers_waiting_;
22 while (writer_active_ || readers_active_ > 0) {
23 write_condition_.SleepCS(critical_section_);
24 }
25 --writers_waiting_;
26 }
27 writer_active_ = true;
28 }
29
30 void RWLockWinXP::ReleaseLockExclusive() {
31 CriticalSectionScoped cs(&critical_section_);
32 writer_active_ = false;
33 if (writers_waiting_ > 0) {
34 write_condition_.Wake();
35 } else if (readers_waiting_ > 0) {
36 read_condition_.WakeAll();
37 }
38 }
39
40 void RWLockWinXP::AcquireLockShared() {
41 CriticalSectionScoped cs(&critical_section_);
42 if (writer_active_ || writers_waiting_ > 0) {
43 ++readers_waiting_;
44
45 while (writer_active_ || writers_waiting_ > 0) {
46 read_condition_.SleepCS(critical_section_);
47 }
48 --readers_waiting_;
49 }
50 ++readers_active_;
51 }
52
53 void RWLockWinXP::ReleaseLockShared() {
54 CriticalSectionScoped cs(&critical_section_);
55 --readers_active_;
56 if (readers_active_ == 0 && writers_waiting_ > 0) {
57 write_condition_.Wake();
58 }
59 }
60
61 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698