Refine comments

This commit is contained in:
Tevin Zhang 2016-06-02 11:48:02 +08:00
parent df1d8a392d
commit 6662858d93
1 changed files with 7 additions and 5 deletions

12
bool.go
View File

@ -18,27 +18,29 @@ func NewBool(ok bool) *AtomicBool {
return ab
}
// AtomicBool is a atomic boolean
// AtomicBool is an atomic Boolean
// Its methods are all atomic, thus safe to be called by
// multiple goroutines simultaneously
// Note: When embedding into a struct, one should always use
// *AtomicBool to avoid copy
type AtomicBool int32
// Set sets the bool to true
// Set sets the Boolean to true
func (ab *AtomicBool) Set() {
atomic.StoreInt32((*int32)(ab), 1)
}
// UnSet sets the bool to false
// UnSet sets the Boolean to false
func (ab *AtomicBool) UnSet() {
atomic.StoreInt32((*int32)(ab), 0)
}
// IsSet returns whether the bool is true
// IsSet returns whether the Boolean is true
func (ab *AtomicBool) IsSet() bool {
return atomic.LoadInt32((*int32)(ab)) == 1
}
// SetTo sets the boolean with given bool
// SetTo sets the boolean with given Boolean
func (ab *AtomicBool) SetTo(yes bool) {
if yes {
atomic.StoreInt32((*int32)(ab), 1)