-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Switch atomic.Value to atomicBool (taken from Go 1.19 stdlib)
- Loading branch information
1 parent
07462bd
commit 70c0cb9
Showing
2 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package queue | ||
|
||
import "sync/atomic" | ||
|
||
// atomicBool is an atomic boolean value. | ||
// The zero value is false. | ||
type atomicBool struct { | ||
v uint32 | ||
} | ||
|
||
// Load atomically loads and returns the value stored in x. | ||
func (x *atomicBool) load() bool { return atomic.LoadUint32(&x.v) != 0 } | ||
|
||
// Store atomically stores val into x. | ||
func (x *atomicBool) store(val bool) { atomic.StoreUint32(&x.v, b32(val)) } | ||
|
||
// b32 returns a uint32 0 or 1 representing b. | ||
func b32(b bool) uint32 { | ||
if b { | ||
return 1 | ||
} | ||
|
||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters