add atomic duration type (#37)
wrapper around existing `Int64` type for atomic operations on `time.Duration` values
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user