base | AtomicIntegerT类

1. 原子自增操作

type __sync_fetch_and_add (type *ptr, type value)

2. 原子比较和交换(设置)操作

type __sync_val_compare_and_swap (type *ptr, type oldval type newval)
bool __sync_bool_compare_and_swap (type *ptr, type oldval type newval)

3. 原子赋值操作

type __sync_lock_test_and_set (type *ptr, type value)

使用这些原子性操作,编译的时候需要加-march=cpu-type

猜你喜欢

转载自www.cnblogs.com/sunbines/p/10279121.html