Documentation
¶
Overview ¶
Package atomicbool provides a type with function interfaces like official sync/atomic.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type B ¶
type B struct {
// contains filtered or unexported fields
}
B is the replacement of bool in atomic scenarios. It is OK to initialize an atomicbool.B with b := atomicbool.B{}
Example ¶
package main import ( "fmt" atomicbool "github.com/Andrew-M-C/go.atomicbool" ) func main() { f := fmt.Println b := atomicbool.New(true) f(b.Load()) b.Store(false) f(b.Load()) swapped := b.CompareAndSwap(false, true) f(swapped, b.Load()) }
Output: true false true true
func New ¶
New returns an atomicbool value with specified boolean value. It is useful when you want to initialize it as true or values by other channel. Otherwise, just use b := atomicbool.B{}.
func (*B) CompareAndSwap ¶
CompareAndSwap executes the compare-and-swap operation for an atomicbool.
Click to show internal directories.
Click to hide internal directories.