| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 return static_cast<T>(base::Barrier_AtomicIncrement( | 24 return static_cast<T>(base::Barrier_AtomicIncrement( |
| 25 &value_, static_cast<base::AtomicWord>(increment))); | 25 &value_, static_cast<base::AtomicWord>(increment))); |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Returns the value after decrementing. | 28 // Returns the value after decrementing. |
| 29 V8_INLINE T Decrement(T decrement) { | 29 V8_INLINE T Decrement(T decrement) { |
| 30 return static_cast<T>(base::Barrier_AtomicIncrement( | 30 return static_cast<T>(base::Barrier_AtomicIncrement( |
| 31 &value_, -static_cast<base::AtomicWord>(decrement))); | 31 &value_, -static_cast<base::AtomicWord>(decrement))); |
| 32 } | 32 } |
| 33 | 33 |
| 34 V8_INLINE T Value() { return static_cast<T>(base::Acquire_Load(&value_)); } | 34 V8_INLINE T Value() const { |
| 35 return static_cast<T>(base::Acquire_Load(&value_)); |
| 36 } |
| 35 | 37 |
| 36 V8_INLINE void SetValue(T new_value) { | 38 V8_INLINE void SetValue(T new_value) { |
| 37 base::Release_Store(&value_, static_cast<base::AtomicWord>(new_value)); | 39 base::Release_Store(&value_, static_cast<base::AtomicWord>(new_value)); |
| 38 } | 40 } |
| 39 | 41 |
| 40 V8_INLINE T operator=(T value) { | 42 V8_INLINE T operator=(T value) { |
| 41 SetValue(value); | 43 SetValue(value); |
| 42 return value; | 44 return value; |
| 43 } | 45 } |
| 44 | 46 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 return static_cast<base::AtomicWord>(1) << element; | 247 return static_cast<base::AtomicWord>(1) << element; |
| 246 } | 248 } |
| 247 | 249 |
| 248 base::AtomicWord bits_; | 250 base::AtomicWord bits_; |
| 249 }; | 251 }; |
| 250 | 252 |
| 251 } // namespace base | 253 } // namespace base |
| 252 } // namespace v8 | 254 } // namespace v8 |
| 253 | 255 |
| 254 #endif // #define V8_ATOMIC_UTILS_H_ | 256 #endif // #define V8_ATOMIC_UTILS_H_ |
| OLD | NEW |