by tevino

tevino / abool

:bulb: Atomic Boolean library for cleaner Go code, optimized for performance yet simple to use.

214 Stars 18 Forks Last release: Not found MIT License 37 Commits 4 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

ABool :bulb:

Go Report Card GoDoc

Atomic Boolean package for Go, optimized for performance yet simple to use.

Designed for cleaner code.


import "github.com/tevino/abool"

cond := abool.New() // default to false

cond.Set() // Sets to true cond.IsSet() // Returns true cond.UnSet() // Sets to false cond.IsNotSet() // Returns true cond.SetTo(any) // Sets to whatever you want cond.SetToIf(new, old) // Sets to new only if the Boolean matches the old, returns whether succeeded cond.Toggle() // Inverts the boolean then returns the value before inverting

// embedding type Foo struct { cond *abool.AtomicBool // always use pointer to avoid copy }


  • Go 1.14.3
  • Linux 4.19.0
goos: linux
goarch: amd64


BenchmarkMutexRead-4 86662128 14.2 ns/op BenchmarkAtomicValueRead-4 1000000000 0.755 ns/op BenchmarkAtomicBoolRead-4 1000000000 0.720 ns/op #

Special thanks to contributors

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.