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

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

Issue 2047433004: content: Add heartbeat trace for CategorizedWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 6 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_posix.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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
95 void Wait(); 95 void Wait();
96 void TimedWait(const TimeDelta& max_time); 96 // TimedWait() returns true on timeout, otherwise returns false.
97 bool TimedWait(const TimeDelta& max_time);
97 98
98 // Broadcast() revives all waiting threads. 99 // Broadcast() revives all waiting threads.
99 void Broadcast(); 100 void Broadcast();
100 // Signal() revives one waiting thread. 101 // Signal() revives one waiting thread.
101 void Signal(); 102 void Signal();
102 103
103 private: 104 private:
104 105
105 #if defined(OS_WIN) 106 #if defined(OS_WIN)
106 CONDITION_VARIABLE cv_; 107 CONDITION_VARIABLE cv_;
107 SRWLOCK* const srwlock_; 108 SRWLOCK* const srwlock_;
108 #elif defined(OS_POSIX) 109 #elif defined(OS_POSIX)
109 pthread_cond_t condition_; 110 pthread_cond_t condition_;
110 pthread_mutex_t* user_mutex_; 111 pthread_mutex_t* user_mutex_;
111 #endif 112 #endif
112 113
113 #if DCHECK_IS_ON() && (defined(OS_WIN) || defined(OS_POSIX)) 114 #if DCHECK_IS_ON() && (defined(OS_WIN) || defined(OS_POSIX))
114 base::Lock* const user_lock_; // Needed to adjust shadow lock state on wait. 115 base::Lock* const user_lock_; // Needed to adjust shadow lock state on wait.
115 #endif 116 #endif
116 117
117 DISALLOW_COPY_AND_ASSIGN(ConditionVariable); 118 DISALLOW_COPY_AND_ASSIGN(ConditionVariable);
118 }; 119 };
119 120
120 } // namespace base 121 } // namespace base
121 122
122 #endif // BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_ 123 #endif // BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_
OLDNEW
« no previous file with comments | « no previous file | base/synchronization/condition_variable_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698