forked from mirror/abool
Polish comments
This commit is contained in:
parent
037d8fa3d5
commit
85c50599ef
6
bool.go
6
bool.go
|
@ -73,12 +73,14 @@ func (ab *AtomicBool) SetToIf(old, new bool) (set bool) {
|
|||
return atomic.CompareAndSwapInt32((*int32)(ab), o, n)
|
||||
}
|
||||
|
||||
// Marshal an AtomicBool into JSON like a normal bool
|
||||
// Marshall behaves the same as if the AtomicBool is a builtin.bool.
|
||||
// NOTE: There's no lock during the process, usually it shouldn't be called with other methods in parallel.
|
||||
func (ab *AtomicBool) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(ab.IsSet())
|
||||
}
|
||||
|
||||
// Unmarshall normal bool's into AtomicBool
|
||||
// Unmarshall behaves the same as if the AtomicBool is a builtin.bool.
|
||||
// NOTE: There's no lock during the process, usually it shouldn't be called with other methods in parallel.
|
||||
func (ab *AtomicBool) UnmarshalJSON(b []byte) error {
|
||||
var v bool
|
||||
if err := json.Unmarshal(b, &v); err != nil {
|
||||
|
|
Loading…
Reference in New Issue