SetIfMax sets the value of the atomic int to the given value if the given value is greater than the current value.
(value int64)
| 1245 | |
| 1246 | // SetIfMax sets the value of the atomic int to the given value if the given value is greater than the current value. |
| 1247 | func (ai *AtomicInt) SetIfMax(value int64) { |
| 1248 | for { |
| 1249 | cur := atomic.LoadInt64(&ai.val) |
| 1250 | if cur >= value { |
| 1251 | return |
| 1252 | } |
| 1253 | |
| 1254 | if atomic.CompareAndSwapInt64(&ai.val, cur, value) { |
| 1255 | return |
| 1256 | } |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | // Add adds the given value to the atomic int. |
| 1261 | func (ai *AtomicInt) Add(value int64) { |
no outgoing calls