mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 23:48:06 -05:00
Refactor to use atomic types (#15625)
* refactor to use atomic types * added changlog fragment file * update change log
This commit is contained in:
@@ -10,18 +10,18 @@ import (
|
||||
|
||||
// Arbitrary start time.
|
||||
var start = time.Date(1990, 1, 2, 0, 0, 0, 0, time.UTC).Round(0)
|
||||
var elapsed int64
|
||||
var elapsed atomic.Int64
|
||||
|
||||
// We provide atomic access to elapsed to avoid data races between multiple
|
||||
// concurrent goroutines during the tests.
|
||||
func getElapsed() time.Duration {
|
||||
return time.Duration(atomic.LoadInt64(&elapsed))
|
||||
return time.Duration(elapsed.Load())
|
||||
}
|
||||
func setElapsed(v time.Duration) {
|
||||
atomic.StoreInt64(&elapsed, int64(v))
|
||||
elapsed.Store(int64(v))
|
||||
}
|
||||
func addToElapsed(v time.Duration) {
|
||||
atomic.AddInt64(&elapsed, int64(v))
|
||||
elapsed.Add(int64(v))
|
||||
}
|
||||
|
||||
func reset(t *testing.T, c *Collector) {
|
||||
|
||||
Reference in New Issue
Block a user