Documentation
¶
Overview ¶
Atomic store and load of bool type.
Copyright 2017 Nicolas S. Dade
bool-in-uint32 atomic store and load.
This type exists because of the aliasing of up to 3 other byte sized variables in the 4 bytes containing a regular Go 'bool' trips up the go -race detection, producing false races, because from Go's point of view we were reading and writing the 4 bytes, even though we were only, and atomically, changing only one.
Copyright 2021 Nicolas S. Dade
Index ¶
Constants ¶
const ( // True32 is the value of a Bool32 set to true. It's useful to initialize a Bool32 to true. True32 = Bool32(1) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bool32 ¶ added in v1.1.0
type Bool32 uint32
Bool32 is a boolean stored in a uint32. It's sole purpose is to avoid go -race false positives which otherwise happen when a regular (1 byte) Go 'bool' is adjacent other variables in memory.
func (*Bool32) CompareAndSwap ¶ added in v1.1.0
CompareAndSwap atomically performs:
if b == old {
b = new
return true
} else {
return false
}