Android的原子操作函数
来源:互联网 发布:物流信息发布平台源码 编辑:程序博客网 时间:2024/05/24 04:52
原文地址:http://book.51cto.com/art/201504/474434.htm
6.1.1 Android的原子操作函数
1.原子变量的加法操作
- int32_t android_atomic_add(int32_t value, volatile int32_t* addr);
原子变量的减法操作可以通过传递负值给加法操作函数来完成。
2.原子变量的自增和自减操作
- int32_t android_atomic_inc(volatile int32_t* addr);
- int32_t android_atomic_dec(volatile int32_t* addr);
3.原子变量的与操作
- int32_t android_atomic_and(int32_t value, volatile int32_t* addr);
4.原子变量的或操作
- int32_t android_atomic_or(int32_t value, volatile int32_t* addr);
5.原子变量的设置
- void android_atomic_acquire_store(int32_t value, volatile int32_t* addr);
- void android_atomic_release_store(int32_t value, volatile int32_t* addr);
6.原子变量的读取
- int32_t android_atomic_acquire_load(volatile const int32_t* addr);
- int32_t android_atomic_release_load(volatile const int32_t* addr);
注意 上面这两个函数从功能上看是一样的,区别只是内存屏障位于读取前还是读取后,下面的两组函数也类似。
7.原子变量的比较并交换
- int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr);
- int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr);
8.还有两个原子变量的宏定义
- #define android_atomic_write android_atomic_release_store
- #define android_atomic_cmpxchg android_atomic_release_cas
0 0
- Android的原子操作函数
- Android的NDK下原子操作函数的应用
- 标准C++库的原子操作函数
- 一些有用的原子操作函数
- 一些原子操作函数
- gcc 原子操作函数
- 原子操作及函数
- Android原子操作的实现原理
- Android原子操作的实现原理
- Android 原子操作函數介紹
- android 原子操作
- 原子操作 Interlocked系列函数
- 原子操作 Interlocked系列函数
- 原子操作 Interlocked系列函数
- gcc内置原子操作函数
- Linux原子操作及函数
- Linux下原子操作函数
- WINCE的原子操作
- Git用户指南
- css3 :hover添加特效
- Queue队列 链式存储实现
- log4j
- Linux 网桥配置命令:brctl
- Android的原子操作函数
- spring+hibernate+struts2整合方案(2,整合细则)
- 第十二周项目1.1实现复数类中的运算符重载(成员函数)
- 删除指定节点
- 配置 linux 开机运行脚本 && setuid & setgid
- second test
- JS循环执行函数setInterval
- JSON的定义
- 深入浅出如何解析xml文件---下篇