Polish comments

This commit is contained in:
Tevin Zhang 2021-05-15 19:31:02 +08:00
parent 037d8fa3d5
commit 85c50599ef
No known key found for this signature in database
GPG Key ID: EE7DA2A50F0960FB
1 changed files with 4 additions and 2 deletions

View File

@ -73,12 +73,14 @@ func (ab *AtomicBool) SetToIf(old, new bool) (set bool) {
return atomic.CompareAndSwapInt32((*int32)(ab), o, n) 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) { func (ab *AtomicBool) MarshalJSON() ([]byte, error) {
return json.Marshal(ab.IsSet()) 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 { func (ab *AtomicBool) UnmarshalJSON(b []byte) error {
var v bool var v bool
if err := json.Unmarshal(b, &v); err != nil { if err := json.Unmarshal(b, &v); err != nil {