一、实例用法 #
1. atomic_t的用法 #
1
2atomic_t g_running_hooks = ATOMIC_INIT(0);
3
4int main() {
5 int count;
6
7 atomic_inc(&g_running_hooks); // 加一
8 atomic_dec(&g_running_hooks); // 减一
9 atomic_set_release(&g_running_hooks, 1); // 设置为1
10 atomic_set_release(&g_running_hooks, 0); // 设置为0
11 count = atomic_read_acquire(&g_running_hooks); // 读取值
12}