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
245 Stars 21 Forks MIT License 54 Commits 2 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

# 104,998
Go
atomic
golang
Linux
39 commits
# 131,945
CSS
Shell
golang
gorouti...
5 commits
# 125,342
Tensorf...
CSS
automat...
lambda
1 commit

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/v2"

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(old, new) // Sets to new only if the Boolean matches the old, returns whether succeeded

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

Benchmark:

  • Go 1.6.2
  • OS X 10.11.4
  • Intel CPU (to be specified)
# Read
BenchmarkMutexRead-4        100000000           21.0 ns/op
BenchmarkAtomicValueRead-4  200000000            6.30 ns/op
BenchmarkAtomicBoolRead-4   300000000            4.21 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.