OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_ATOMIC_UTILS_H_ | 5 #ifndef V8_ATOMIC_UTILS_H_ |
6 #define V8_ATOMIC_UTILS_H_ | 6 #define V8_ATOMIC_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 | 9 |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
11 #include "src/base/macros.h" | 11 #include "src/base/macros.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace base { |
15 | 15 |
16 template <class T> | 16 template <class T> |
17 class AtomicNumber { | 17 class AtomicNumber { |
18 public: | 18 public: |
19 AtomicNumber() : value_(0) {} | 19 AtomicNumber() : value_(0) {} |
20 explicit AtomicNumber(T initial) : value_(initial) {} | 20 explicit AtomicNumber(T initial) : value_(initial) {} |
21 | 21 |
22 // Returns the newly set value. | 22 // Returns the newly set value. |
23 V8_INLINE T Increment(T increment) { | 23 V8_INLINE T Increment(T increment) { |
24 return static_cast<T>(base::Barrier_AtomicIncrement( | 24 return static_cast<T>(base::Barrier_AtomicIncrement( |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return base::Acquire_Load(&bits_); | 162 return base::Acquire_Load(&bits_); |
163 } | 163 } |
164 | 164 |
165 V8_INLINE base::AtomicWord Mask(E element) const { | 165 V8_INLINE base::AtomicWord Mask(E element) const { |
166 return static_cast<base::AtomicWord>(1) << element; | 166 return static_cast<base::AtomicWord>(1) << element; |
167 } | 167 } |
168 | 168 |
169 base::AtomicWord bits_; | 169 base::AtomicWord bits_; |
170 }; | 170 }; |
171 | 171 |
172 } // namespace internal | 172 } // namespace base |
173 } // namespace v8 | 173 } // namespace v8 |
174 | 174 |
175 #endif // #define V8_ATOMIC_UTILS_H_ | 175 #endif // #define V8_ATOMIC_UTILS_H_ |
OLD | NEW |