天天看點

Android atomic

在platform21之前都能夠好好的使用一下這兩個函數,用于原子操作的加減。但是當使用platform21時這裡發生了一點變化,頭檔案sys/atomics.h也去掉了,改為stdatomic.h。

__atomic_dec(void *)              __atomic_inc(void *)           

常用的這兩個接口也改為更加靈活的方式:

__sync_fetch_and_add(void *, int)              __sync_fetch_and_sub(void *, int)                  // test              int mRefCount = 2;              __sync_fetch_and_add(&mRefCount, 1);