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

Side by Side Diff: src/base/platform/semaphore.h

Issue 2395553002: Reland "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/platform/platform.h ('k') | src/base/platform/time.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_SEMAPHORE_H_ 5 #ifndef V8_BASE_PLATFORM_SEMAPHORE_H_
6 #define V8_BASE_PLATFORM_SEMAPHORE_H_ 6 #define V8_BASE_PLATFORM_SEMAPHORE_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 #if V8_OS_WIN 10 #if V8_OS_WIN
10 #include "src/base/win32-headers.h" 11 #include "src/base/win32-headers.h"
11 #endif 12 #endif
12 13
13 #if V8_OS_MACOSX 14 #if V8_OS_MACOSX
14 #include <mach/semaphore.h> // NOLINT 15 #include <mach/semaphore.h> // NOLINT
15 #elif V8_OS_POSIX 16 #elif V8_OS_POSIX
16 #include <semaphore.h> // NOLINT 17 #include <semaphore.h> // NOLINT
17 #endif 18 #endif
18 19
19 namespace v8 { 20 namespace v8 {
20 namespace base { 21 namespace base {
21 22
22 // Forward declarations. 23 // Forward declarations.
23 class TimeDelta; 24 class TimeDelta;
24 25
25 // ---------------------------------------------------------------------------- 26 // ----------------------------------------------------------------------------
26 // Semaphore 27 // Semaphore
27 // 28 //
28 // A semaphore object is a synchronization object that maintains a count. The 29 // A semaphore object is a synchronization object that maintains a count. The
29 // count is decremented each time a thread completes a wait for the semaphore 30 // count is decremented each time a thread completes a wait for the semaphore
30 // object and incremented each time a thread signals the semaphore. When the 31 // object and incremented each time a thread signals the semaphore. When the
31 // count reaches zero, threads waiting for the semaphore blocks until the 32 // count reaches zero, threads waiting for the semaphore blocks until the
32 // count becomes non-zero. 33 // count becomes non-zero.
33 34
34 class Semaphore final { 35 class V8_BASE_EXPORT Semaphore final {
35 public: 36 public:
36 explicit Semaphore(int count); 37 explicit Semaphore(int count);
37 ~Semaphore(); 38 ~Semaphore();
38 39
39 // Increments the semaphore counter. 40 // Increments the semaphore counter.
40 void Signal(); 41 void Signal();
41 42
42 // Decrements the semaphore counter if it is positive, or blocks until it 43 // Decrements the semaphore counter if it is positive, or blocks until it
43 // becomes positive and then decrements the counter. 44 // becomes positive and then decrements the counter.
44 void Wait(); 45 void Wait();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 typedef typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>, 93 typedef typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>,
93 ThreadSafeInitOnceTrait>::type type; 94 ThreadSafeInitOnceTrait>::type type;
94 }; 95 };
95 96
96 #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER 97 #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER
97 98
98 } // namespace base 99 } // namespace base
99 } // namespace v8 100 } // namespace v8
100 101
101 #endif // V8_BASE_PLATFORM_SEMAPHORE_H_ 102 #endif // V8_BASE_PLATFORM_SEMAPHORE_H_
OLDNEW
« no previous file with comments | « src/base/platform/platform.h ('k') | src/base/platform/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698