add atomic duration type (#37)

wrapper around existing `Int64` type for atomic operations on `time.Duration` values
This commit is contained in:
Nathan Jordan
2018-05-01 10:38:09 -07:00
committed by GitHub
parent 8474b86a5a
commit 1ea20fb1cb
3 changed files with 84 additions and 11 deletions

View File

@@ -34,17 +34,18 @@ const (
)
var _stressTests = map[string]func() func(){
"i32/std": stressStdInt32,
"i32": stressInt32,
"i64/std": stressStdInt32,
"i64": stressInt64,
"u32/std": stressStdUint32,
"u32": stressUint32,
"u64/std": stressStdUint64,
"u64": stressUint64,
"f64": stressFloat64,
"bool": stressBool,
"string": stressString,
"i32/std": stressStdInt32,
"i32": stressInt32,
"i64/std": stressStdInt32,
"i64": stressInt64,
"u32/std": stressStdUint32,
"u32": stressUint32,
"u64/std": stressStdUint64,
"u64": stressUint64,
"f64": stressFloat64,
"bool": stressBool,
"string": stressString,
"duration": stressDuration,
}
func TestStress(t *testing.T) {
@@ -243,3 +244,15 @@ func stressString() func() {
atom.Store("")
}
}
func stressDuration() func() {
var atom = NewDuration(0)
return func() {
atom.Load()
atom.Add(1)
atom.Sub(2)
atom.CAS(1, 0)
atom.Swap(5)
atom.Store(1)
}
}