Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/lazy-instance.h" | 8 #include "src/base/lazy-instance.h" |
| 9 #if V8_OS_WIN | 9 #if V8_OS_WIN |
| 10 #include "src/base/win32-headers.h" | 10 #include "src/base/win32-headers.h" |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #if V8_OS_MACOSX | 13 #if V8_OS_MACOSX |
| 14 #include <mach/semaphore.h> // NOLINT | 14 #include <mach/semaphore.h> // NOLINT |
| 15 #elif V8_OS_POSIX | 15 #elif V8_OS_POSIX |
| 16 #include <semaphore.h> // NOLINT | 16 #include <semaphore.h> // NOLINT |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 namespace v8 { | 19 namespace v8 { |
| 20 namespace base { | 20 namespace base { |
| 21 | 21 |
| 22 #if V8_OS_AIX | |
| 23 // On aix sem_t is of type int | |
| 24 const uintptr_t kSemaphoreAlignmentMask = sizeof(int) - 1; | |
|
jochen (gone - plz use gerrit)
2016/05/02 16:15:45
Any reason this is defined in the header?
| |
| 25 #else | |
| 26 const uintptr_t kSemaphoreAlignmentMask = sizeof(void*) - 1; | |
| 27 #endif | |
| 28 | |
| 22 // Forward declarations. | 29 // Forward declarations. |
| 23 class TimeDelta; | 30 class TimeDelta; |
| 24 | 31 |
| 25 // ---------------------------------------------------------------------------- | 32 // ---------------------------------------------------------------------------- |
| 26 // Semaphore | 33 // Semaphore |
| 27 // | 34 // |
| 28 // A semaphore object is a synchronization object that maintains a count. The | 35 // 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 | 36 // 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 | 37 // object and incremented each time a thread signals the semaphore. When the |
| 31 // count reaches zero, threads waiting for the semaphore blocks until the | 38 // count reaches zero, threads waiting for the semaphore blocks until the |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 typedef typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>, | 100 typedef typename LazyDynamicInstance<Semaphore, CreateSemaphoreTrait<N>, |
| 94 ThreadSafeInitOnceTrait>::type type; | 101 ThreadSafeInitOnceTrait>::type type; |
| 95 }; | 102 }; |
| 96 | 103 |
| 97 #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER | 104 #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER |
| 98 | 105 |
| 99 } // namespace base | 106 } // namespace base |
| 100 } // namespace v8 | 107 } // namespace v8 |
| 101 | 108 |
| 102 #endif // V8_BASE_PLATFORM_SEMAPHORE_H_ | 109 #endif // V8_BASE_PLATFORM_SEMAPHORE_H_ |
| OLD | NEW |