这种填充方式能解决 false sharing 吗,
type PaddedStruct struct {
_ CacheLinePad
n int
}
type CacheLinePad struct {
_ [CacheLinePadSize]byte
}
const CacheLinePadSize = 64
CacheLinePad 后面的字段,是怎么避免和其他结构体不共享一个 Cache 块了,把 CacheLinePad 放在第一个字段,只能避免和它前面的数据不在一个 cache 块吧,是不是应该这样
type PaddedStruct struct {
_ CacheLinePad
n int
_ CacheLinePad
}