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

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

Issue 2391893003: base: Update comment for ConditionVariable::Wait() function. (Closed)
Patch Set: Created 4 years, 2 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 | no next file » | 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 class TimeDelta; 84 class TimeDelta;
85 85
86 class BASE_EXPORT ConditionVariable { 86 class BASE_EXPORT ConditionVariable {
87 public: 87 public:
88 // Construct a cv for use with ONLY one user lock. 88 // Construct a cv for use with ONLY one user lock.
89 explicit ConditionVariable(Lock* user_lock); 89 explicit ConditionVariable(Lock* user_lock);
90 90
91 ~ConditionVariable(); 91 ~ConditionVariable();
92 92
93 // Wait() releases the caller's critical section atomically as it starts to 93 // Wait() releases the caller's critical section atomically as it starts to
94 // sleep, and the reacquires it when it is signaled. 94 // sleep, and the reacquires it when it is signaled. The wait functions are
95 // susceptible to spurious wakeups. (See usage note 1 for more details.)
95 void Wait(); 96 void Wait();
96 void TimedWait(const TimeDelta& max_time); 97 void TimedWait(const TimeDelta& max_time);
97 98
98 // Broadcast() revives all waiting threads. 99 // Broadcast() revives all waiting threads. (See usage note 2 for more
100 // details.)
99 void Broadcast(); 101 void Broadcast();
100 // Signal() revives one waiting thread. 102 // Signal() revives one waiting thread.
101 void Signal(); 103 void Signal();
102 104
103 private: 105 private:
104 106
105 #if defined(OS_WIN) 107 #if defined(OS_WIN)
106 CONDITION_VARIABLE cv_; 108 CONDITION_VARIABLE cv_;
107 SRWLOCK* const srwlock_; 109 SRWLOCK* const srwlock_;
108 #elif defined(OS_POSIX) 110 #elif defined(OS_POSIX)
109 pthread_cond_t condition_; 111 pthread_cond_t condition_;
110 pthread_mutex_t* user_mutex_; 112 pthread_mutex_t* user_mutex_;
111 #endif 113 #endif
112 114
113 #if DCHECK_IS_ON() && (defined(OS_WIN) || defined(OS_POSIX)) 115 #if DCHECK_IS_ON() && (defined(OS_WIN) || defined(OS_POSIX))
114 base::Lock* const user_lock_; // Needed to adjust shadow lock state on wait. 116 base::Lock* const user_lock_; // Needed to adjust shadow lock state on wait.
115 #endif 117 #endif
116 118
117 DISALLOW_COPY_AND_ASSIGN(ConditionVariable); 119 DISALLOW_COPY_AND_ASSIGN(ConditionVariable);
118 }; 120 };
119 121
120 } // namespace base 122 } // namespace base
121 123
122 #endif // BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_ 124 #endif // BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698