原子操作函数

分为下面系列函数,其中Xxx可以是Int32/Int64/Uint32/Uint64/Uintptr/Pointer其中一种。

1.SwapXxx系列:交换新旧值;

// SwapInt32 atomically stores new into *addr and returns the previous *addr value.
func SwapInt32(addr *int32, new int32) (old int32)

2.CompareAndSwapXxx系列:比较并交换;

// CompareAndSwapInt32 executes the compare-and-swap operation for an int32 value.
func CompareAndSwapInt32(addr *int32, old, new int32) (swapped bool)

3.AddXxx系列:加减;

// AddInt32 atomically adds delta to *addr and returns the new value.
func AddInt32(addr *int32, delta int32) (new int32)

4.LoadXxx系列:读取;

// LoadInt32 atomically loads *addr.
func LoadInt32(addr *int32) (val int32)

5.StoreXxx系列:保存;

// StoreInt32 atomically stores val into *addr.
func StoreInt32(addr *int32, val int32)

以上。

Golang atomic的更多相关文章

  1. golang sync/atomic

    刚刚学习golang原子操作处理的时候发现github上面一个比较不错的golang学习项目 附上链接:https://github.com/polaris1119/The-Golang-Standa ...

  2. golang语言中sync/atomic包的学习与使用

    package main; import ( "sync/atomic" "fmt" "sync" ) //atomic包提供了底层的原子级 ...

  3. golang中的原子操作atomic包

    1. 概念 原子操作 atomic 包 加锁操作涉及到内核态的上下文切换,比较耗时,代价高, 针对基本数据类型我们还可以使用原子操作来保证并发的安全, 因为原子操作是go语言提供的方法,我们在用户态就 ...

  4. 【GoLang】golang中 channel 实现同步 与mutex/atomic 实现同步的讨论

    参考资料: https://groups.google.com/forum/#!topic/golang-china/q4pFH-AGnfs

  5. [转]50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

    http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/ 50 Shades of Go: Traps, Gotc ...

  6. [Golang]Go Packages

    ---------------------------------------------------------------------------------------------------- ...

  7. win下 golang 跨平台编译

    mac 下编译其他平台的执行文件方式请参看这篇文章,http://www.cnblogs.com/ghj1976/archive/2013/04/19/3030703.html  本篇文章是win下的 ...

  8. Golang性能调优入门

    如何利用golang自带的profile工具进行应用程序的性能调优,前一段时间我做的日志分析系统在线上遇到了一个问题,就是分任务的系统down机了,日志处理延迟了10几个小时,这个时候任务分发系统重启 ...

  9. Go语言(golang)开源项目大全

    转http://www.open-open.com/lib/view/open1396063913278.html内容目录Astronomy构建工具缓存云计算命令行选项解析器命令行工具压缩配置文件解析 ...

随机推荐

  1. Python爬虫(三)——对豆瓣图书各模块评论数与评分图形化分析

    文化         经管 ....略 结论: 一个模块的评分与评论数相关,评分为 [8.8——9.2] 之间的书籍评论数往往是模块中最多的

  2. Linux维护常用命令

    1.查看Linux占用内存/CPU最多的进程 可以使用以下命令查使用内存最多的10个进程 #ps -aux | sort -k4nr | head -n 10可以使用以下命令查使用CPU最多的10个进 ...

  3. CentOS 7下搭建配置 SVN 服务器

    原文链接:https://www.cnblogs.com/tdalcn/p/6937714.html 同步:http://blog.csdn.net/u011884440/article/detail ...

  4. day5 python

    一.常量 在Python中没有一个专门的语法代表常量,程序员约定俗成用变量名全部大写代表常量.AGE_OF_OLFBOY=73二.基本运算符的补充1.算数运算符 print(10/3) print(1 ...

  5. C++的STL之map自动排序特性

    #include <iostream> #include <map> using namespace std; int main() {方法一: map<int,int& ...

  6. 【python38--面向对象继承】

    一.继承 1.语法:class DerivedClassName(BaseClassName):子类继承父类 >>> class Parent: def hello(self): p ...

  7. python脚本解析json文件

    python脚本解析json文件 没写完.但是有效果.初次尝试,写的比较不简洁... 比较烦的地方在于: 1,中文编码: pSpecs.decode('raw_unicode_escape') 2,花 ...

  8. github帐户和仓库的创建

    sign up is registration and sign in is logging in for "in" is to enter an existing account ...

  9. netty基础

    1,ServerBootstrap  [Bootstrap] 

  10. 深度学习课程笔记(十七)Meta-learning (Model Agnostic Meta Learning)

    深度学习课程笔记(十七)Meta-learning (Model Agnostic Meta Learning) 2018-08-09 12:21:33 The video tutorial can ...