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

Side by Side Diff: src/base/platform/condition-variable.h

Issue 2399323002: Reland of land "Turn libbase into a component" (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 | « src/base/once.h ('k') | src/base/platform/mutex.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project 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 #ifndef V8_BASE_PLATFORM_CONDITION_VARIABLE_H_ 5 #ifndef V8_BASE_PLATFORM_CONDITION_VARIABLE_H_
6 #define V8_BASE_PLATFORM_CONDITION_VARIABLE_H_ 6 #define V8_BASE_PLATFORM_CONDITION_VARIABLE_H_
7 7
8 #include "src/base/base-export.h"
8 #include "src/base/lazy-instance.h" 9 #include "src/base/lazy-instance.h"
9 #include "src/base/platform/mutex.h" 10 #include "src/base/platform/mutex.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace base { 13 namespace base {
13 14
14 // Forward declarations. 15 // Forward declarations.
15 class ConditionVariableEvent; 16 class ConditionVariableEvent;
16 class TimeDelta; 17 class TimeDelta;
17 18
18 // ----------------------------------------------------------------------------- 19 // -----------------------------------------------------------------------------
19 // ConditionVariable 20 // ConditionVariable
20 // 21 //
21 // This class is a synchronization primitive that can be used to block a thread, 22 // This class is a synchronization primitive that can be used to block a thread,
22 // or multiple threads at the same time, until: 23 // or multiple threads at the same time, until:
23 // - a notification is received from another thread, 24 // - a notification is received from another thread,
24 // - a timeout expires, or 25 // - a timeout expires, or
25 // - a spurious wakeup occurs 26 // - a spurious wakeup occurs
26 // Any thread that intends to wait on a ConditionVariable has to acquire a lock 27 // Any thread that intends to wait on a ConditionVariable has to acquire a lock
27 // on a Mutex first. The |Wait()| and |WaitFor()| operations atomically release 28 // on a Mutex first. The |Wait()| and |WaitFor()| operations atomically release
28 // the mutex and suspend the execution of the calling thread. When the condition 29 // the mutex and suspend the execution of the calling thread. When the condition
29 // variable is notified, the thread is awakened, and the mutex is reacquired. 30 // variable is notified, the thread is awakened, and the mutex is reacquired.
30 31
31 class ConditionVariable final { 32 class V8_BASE_EXPORT ConditionVariable final {
32 public: 33 public:
33 ConditionVariable(); 34 ConditionVariable();
34 ~ConditionVariable(); 35 ~ConditionVariable();
35 36
36 // If any threads are waiting on this condition variable, calling 37 // If any threads are waiting on this condition variable, calling
37 // |NotifyOne()| unblocks one of the waiting threads. 38 // |NotifyOne()| unblocks one of the waiting threads.
38 void NotifyOne(); 39 void NotifyOne();
39 40
40 // Unblocks all threads currently waiting for this condition variable. 41 // Unblocks all threads currently waiting for this condition variable.
41 void NotifyAll(); 42 void NotifyAll();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 typedef LazyStaticInstance< 111 typedef LazyStaticInstance<
111 ConditionVariable, DefaultConstructTrait<ConditionVariable>, 112 ConditionVariable, DefaultConstructTrait<ConditionVariable>,
112 ThreadSafeInitOnceTrait>::type LazyConditionVariable; 113 ThreadSafeInitOnceTrait>::type LazyConditionVariable;
113 114
114 #define LAZY_CONDITION_VARIABLE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER 115 #define LAZY_CONDITION_VARIABLE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER
115 116
116 } // namespace base 117 } // namespace base
117 } // namespace v8 118 } // namespace v8
118 119
119 #endif // V8_BASE_PLATFORM_CONDITION_VARIABLE_H_ 120 #endif // V8_BASE_PLATFORM_CONDITION_VARIABLE_H_
OLDNEW
« no previous file with comments | « src/base/once.h ('k') | src/base/platform/mutex.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698