From 85c50599ef5311794fcb231666d36e395780fff7 Mon Sep 17 00:00:00 2001 From: Tevin Zhang Date: Sat, 15 May 2021 19:31:02 +0800 Subject: [PATCH] Polish comments --- bool.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bool.go b/bool.go index 4c06c71..90e903c 100644 --- a/bool.go +++ b/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 {