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

Side by Side Diff: base/synchronization/condition_variable.h

Issue 1864323002: Migrate from CRITICAL_SECTION to SRWLOCK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cv
Patch Set: Update Comment Created 4 years, 8 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 | base/synchronization/condition_variable_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ConditionVariable wraps pthreads condition variable synchronization or, on 5 // ConditionVariable wraps pthreads condition variable synchronization or, on
6 // Windows, simulates it. This functionality is very helpful for having 6 // Windows, simulates it. This functionality is very helpful for having
7 // several threads wait for an event, as is common with a thread pool managed 7 // several threads wait for an event, as is common with a thread pool managed
8 // by a master. The meaning of such an event in the (worker) thread pool 8 // by a master. The meaning of such an event in the (worker) thread pool
9 // scenario is that additional tasks are now available for processing. It is 9 // scenario is that additional tasks are now available for processing. It is
10 // used in Chrome in the DNS prefetching system to notify worker threads that 10 // used in Chrome in the DNS prefetching system to notify worker threads that
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Broadcast() revives all waiting threads. 98 // Broadcast() revives all waiting threads.
99 void Broadcast(); 99 void Broadcast();
100 // Signal() revives one waiting thread. 100 // Signal() revives one waiting thread.
101 void Signal(); 101 void Signal();
102 102
103 private: 103 private:
104 104
105 #if defined(OS_WIN) 105 #if defined(OS_WIN)
106 CONDITION_VARIABLE cv_; 106 CONDITION_VARIABLE cv_;
107 CRITICAL_SECTION* const crit_sec_; 107 SRWLOCK* const srwlock_;
108 #elif defined(OS_POSIX) 108 #elif defined(OS_POSIX)
109 pthread_cond_t condition_; 109 pthread_cond_t condition_;
110 pthread_mutex_t* user_mutex_; 110 pthread_mutex_t* user_mutex_;
111 #endif 111 #endif
112 112
113 #if DCHECK_IS_ON() && (defined(OS_WIN) || defined(OS_POSIX)) 113 #if DCHECK_IS_ON() && (defined(OS_WIN) || defined(OS_POSIX))
114 base::Lock* const user_lock_; // Needed to adjust shadow lock state on wait. 114 base::Lock* const user_lock_; // Needed to adjust shadow lock state on wait.
115 #endif 115 #endif
116 116
117 DISALLOW_COPY_AND_ASSIGN(ConditionVariable); 117 DISALLOW_COPY_AND_ASSIGN(ConditionVariable);
118 }; 118 };
119 119
120 } // namespace base 120 } // namespace base
121 121
122 #endif // BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_ 122 #endif // BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_
OLDNEW
« no previous file with comments | « no previous file | base/synchronization/condition_variable_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698