Need help with abool?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

tevino
223 Stars 18 Forks MIT License 37 Commits 0 Opened issues

Description

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

Services available

!
?

Need anything else?

Contributors list

# 101,552
Go
atomic
golang
Linux
31 commits
# 140,415
TypeScr...
HTML
Shell
gorouti...
5 commits

ABool :bulb:

Go Report Card GoDoc

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

Designed for cleaner code.

Usage

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 }

Benchmark

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

Read

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.