equal
deleted
inserted
replaced
28 // Implementation of class atomic |
28 // Implementation of class atomic |
29 |
29 |
30 // Implement ADD using a CAS loop. |
30 // Implement ADD using a CAS loop. |
31 template<size_t byte_size> |
31 template<size_t byte_size> |
32 struct Atomic::PlatformAdd { |
32 struct Atomic::PlatformAdd { |
33 template<typename I, typename D> |
33 template<typename D, typename I> |
34 inline D operator()(I add_value, D volatile* dest, atomic_memory_order order) const { |
34 inline D operator()(D volatile* dest, I add_value, atomic_memory_order order) const { |
35 D old_value = *dest; |
35 D old_value = *dest; |
36 while (true) { |
36 while (true) { |
37 D new_value = old_value + add_value; |
37 D new_value = old_value + add_value; |
38 D result = cmpxchg(new_value, dest, old_value); |
38 D result = cmpxchg(new_value, dest, old_value); |
39 if (result == old_value) break; |
39 if (result == old_value) break; |