Ai
1 Star 0 Fork 2

王布衣/pkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cursor.go 445 Bytes
一键复制 编辑 原始数据 按行查看 历史
package fastqueue
import "sync/atomic"
const (
defaultCursorValue = -1
)
type Cursor [8]int64 // prevent false sharing of the sequence cursor by padding the CPU cache line with 64 *bytes* of data.
func NewCursor() *Cursor {
var this Cursor
this[0] = defaultCursorValue
return &this
}
func (this *Cursor) Store(value int64) {
atomic.StoreInt64(&this[0], value)
}
func (this *Cursor) Load() int64 {
return atomic.LoadInt64(&this[0])
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/quant1x/pkg.git
git@gitee.com:quant1x/pkg.git
quant1x
pkg
pkg
v0.5.2

搜索帮助