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

Side by Side Diff: base/condition_variable.h

Issue 118162: Reduce header dependencies in base/ (Closed)
Patch Set: Created 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // thread that has Wait()ed the longest is selected. The default policy 58 // thread that has Wait()ed the longest is selected. The default policy
59 // may improve performance, as the selected thread may have a greater chance of 59 // may improve performance, as the selected thread may have a greater chance of
60 // having some of its stack data in various CPU caches. 60 // having some of its stack data in various CPU caches.
61 // 61 //
62 // For a discussion of the many very subtle implementation details, see the FAQ 62 // For a discussion of the many very subtle implementation details, see the FAQ
63 // at the end of condition_variable_win.cc. 63 // at the end of condition_variable_win.cc.
64 64
65 #ifndef BASE_CONDITION_VARIABLE_H_ 65 #ifndef BASE_CONDITION_VARIABLE_H_
66 #define BASE_CONDITION_VARIABLE_H_ 66 #define BASE_CONDITION_VARIABLE_H_
67 67
68 #include "build/build_config.h"
69
70 #if defined(OS_WIN)
71 #include <windows.h>
72 #elif defined(OS_POSIX)
73 #include <pthread.h>
74 #endif
75
76 #include "base/basictypes.h"
68 #include "base/lock.h" 77 #include "base/lock.h"
69 78
70 namespace base { 79 namespace base {
71 class TimeDelta; 80 class TimeDelta;
72 } 81 }
73 82
74 class ConditionVariable { 83 class ConditionVariable {
75 public: 84 public:
76 // Construct a cv for use with ONLY one user lock. 85 // Construct a cv for use with ONLY one user lock.
77 explicit ConditionVariable(Lock* user_lock); 86 explicit ConditionVariable(Lock* user_lock);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 174
166 pthread_cond_t condition_; 175 pthread_cond_t condition_;
167 pthread_mutex_t* user_mutex_; 176 pthread_mutex_t* user_mutex_;
168 177
169 #endif 178 #endif
170 179
171 DISALLOW_COPY_AND_ASSIGN(ConditionVariable); 180 DISALLOW_COPY_AND_ASSIGN(ConditionVariable);
172 }; 181 };
173 182
174 #endif // BASE_CONDITION_VARIABLE_H_ 183 #endif // BASE_CONDITION_VARIABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698