startRefresh attempts to acquire the refresh guard. Returns (token, true) on success; (0, false) if another refresh is already in progress. The caller must pass the returned token to endRefresh when the refresh completes.
()
| 99 | // Returns (token, true) on success; (0, false) if another refresh is already in progress. |
| 100 | // The caller must pass the returned token to endRefresh when the refresh completes. |
| 101 | func (a *App) startRefresh() (uint64, bool) { |
| 102 | token := uint64(time.Now().UnixNano()) | 1 // ensure nonzero |
| 103 | if a.refreshGen.CompareAndSwap(0, token) { |
| 104 | return token, true |
| 105 | } |
| 106 | return 0, false |
| 107 | } |
| 108 | |
| 109 | // forceNewRefresh unconditionally acquires the refresh guard with a new token, |
| 110 | // discarding any in-flight refresh. Old callbacks whose endRefresh calls will be |
no outgoing calls
no test coverage detected