Extend structs rather than embed, when possible

This commit is contained in:
Jason A. Donenfeld
2019-01-03 19:04:00 +01:00
parent dff424baf8
commit 89d2c5ed7a
16 changed files with 213 additions and 215 deletions

View File

@ -17,11 +17,11 @@ const (
)
type AtomicBool struct {
flag int32
int32
}
func (a *AtomicBool) Get() bool {
return atomic.LoadInt32(&a.flag) == AtomicTrue
return atomic.LoadInt32(&a.int32) == AtomicTrue
}
func (a *AtomicBool) Swap(val bool) bool {
@ -29,7 +29,7 @@ func (a *AtomicBool) Swap(val bool) bool {
if val {
flag = AtomicTrue
}
return atomic.SwapInt32(&a.flag, flag) == AtomicTrue
return atomic.SwapInt32(&a.int32, flag) == AtomicTrue
}
func (a *AtomicBool) Set(val bool) {
@ -37,7 +37,7 @@ func (a *AtomicBool) Set(val bool) {
if val {
flag = AtomicTrue
}
atomic.StoreInt32(&a.flag, flag)
atomic.StoreInt32(&a.int32, flag)
}
func min(a, b uint) uint {