updateUpdatedAtMs atomically advances updatedAtUnixMs if newUpdatedAt is newer. Returns true if updatedAtUnixMs was advanced.
(newUpdatedAt int64)
| 64 | // updateUpdatedAtMs atomically advances updatedAtUnixMs if newUpdatedAt is newer. |
| 65 | // Returns true if updatedAtUnixMs was advanced. |
| 66 | func (v *baseSharedVariable) updateUpdatedAtMs(newUpdatedAt int64) bool { |
| 67 | for { |
| 68 | current := v.updatedAtUnixMs.Load() |
| 69 | if newUpdatedAt <= current { |
| 70 | return false |
| 71 | } |
| 72 | if v.updatedAtUnixMs.CompareAndSwap(current, newUpdatedAt) { |
| 73 | return true |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // advanceTimestampPast advances updatedAtUnixMs to be strictly greater than remoteTs. |
| 79 | // Uses current wall clock if it's newer, otherwise uses remoteTs + 1. |