diff options
author | 2024-09-26 19:23:41 +0000 | |
---|---|---|
committer | 2024-09-26 19:23:41 +0000 | |
commit | f3e2d36d6455e6d16aba833bdf64806377c8178f (patch) | |
tree | 8a1e87f349205e8073b72df6e5349c553db80a17 /vendor/codeberg.org/gruf/go-atomics/bool.go | |
parent | [chore] Fix some contrast issues in themes; performance tweaks (#3358) (diff) | |
download | gotosocial-f3e2d36d6455e6d16aba833bdf64806377c8178f.tar.xz |
[chore] update go-sched pkg (#3357)
* update go-sched to v1.2.4 which removes some now unused dependencies
* whoops, remove test output
Diffstat (limited to 'vendor/codeberg.org/gruf/go-atomics/bool.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-atomics/bool.go | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/vendor/codeberg.org/gruf/go-atomics/bool.go b/vendor/codeberg.org/gruf/go-atomics/bool.go deleted file mode 100644 index 52660d356..000000000 --- a/vendor/codeberg.org/gruf/go-atomics/bool.go +++ /dev/null @@ -1,47 +0,0 @@ -package atomics - -import "sync/atomic" - -// Bool provides user-friendly means of performing atomic operations on bool types. -type Bool uint32 - -// NewBool will return a new Bool instance initialized with zero value. -func NewBool() *Bool { - return new(Bool) -} - -// Store will atomically store bool value in address contained within i. -func (b *Bool) Store(val bool) { - atomic.StoreUint32((*uint32)(b), fromBool(val)) -} - -// Load will atomically load bool value at address contained within i. -func (b *Bool) Load() bool { - return toBool(atomic.LoadUint32((*uint32)(b))) -} - -// CAS performs a compare-and-swap for a(n) bool value at address contained within i. -func (b *Bool) CAS(cmp, swp bool) bool { - return atomic.CompareAndSwapUint32((*uint32)(b), fromBool(cmp), fromBool(swp)) -} - -// Swap atomically stores new bool value into address contained within i, and returns previous value. -func (b *Bool) Swap(swp bool) bool { - return toBool(atomic.SwapUint32((*uint32)(b), fromBool(swp))) -} - -// toBool converts uint32 value to bool. -func toBool(u uint32) bool { - if u == 0 { - return false - } - return true -} - -// fromBool converts from bool to uint32 value. -func fromBool(b bool) uint32 { - if b { - return 1 - } - return 0 -} |