Documentation ¶
Overview ¶
Package atomicvar provides atomic Boolean type for cleaner code and better performance.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomicBoolInt32 ¶
type AtomicBoolInt32 int32
AtomicBoolInt32 is an atomic Boolean Its methods are all atomic, thus safe to be called by multiple goroutines simultaneously Note: When embedding into a struct, one should always use *AtomicBoolInt32 to avoid copy
Example ¶
cond := New() // default to false cond.Set() // set to true cond.IsSet() // returns true cond.UnSet() // set to false cond.SetTo(true) // set to whatever you want
Output:
func NewBool ¶
func NewBool(ok bool) *AtomicBoolInt32
NewBool creates an AtomicBoolInt32 with given default value
func (*AtomicBoolInt32) IsSet ¶
func (ab *AtomicBoolInt32) IsSet() bool
IsTrue returns whether the Boolean is true
func (*AtomicBoolInt32) SetTo ¶
func (ab *AtomicBoolInt32) SetTo(yes bool)
SetTo sets the boolean with given Boolean
func (*AtomicBoolInt32) SetToIf ¶
func (ab *AtomicBoolInt32) SetToIf(old, new bool) (set bool)
SetToIf sets the Boolean to new only if the Boolean matches the old Returns whether the set was done
type AtomicBoolUint32 ¶
type AtomicBoolUint32 uint32
func (*AtomicBoolUint32) IsFalse ¶
func (b *AtomicBoolUint32) IsFalse() bool
func (*AtomicBoolUint32) IsTrue ¶
func (b *AtomicBoolUint32) IsTrue() bool
func (*AtomicBoolUint32) SetFalse ¶
func (b *AtomicBoolUint32) SetFalse()
func (*AtomicBoolUint32) SetTrue ¶
func (b *AtomicBoolUint32) SetTrue()
Click to show internal directories.
Click to hide internal directories.