Introduce an atomic type-safe wrapper around error type. (#42)
This commit is contained in:
committed by
Prashant Varanasi
parent
ca68046243
commit
bb9a8edc0f
@@ -21,6 +21,7 @@
|
||||
package atomic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math"
|
||||
"runtime"
|
||||
"sync"
|
||||
@@ -46,6 +47,7 @@ var _stressTests = map[string]func() func(){
|
||||
"bool": stressBool,
|
||||
"string": stressString,
|
||||
"duration": stressDuration,
|
||||
"error": stressError,
|
||||
}
|
||||
|
||||
func TestStress(t *testing.T) {
|
||||
@@ -256,3 +258,17 @@ func stressDuration() func() {
|
||||
atom.Store(1)
|
||||
}
|
||||
}
|
||||
|
||||
func stressError() func() {
|
||||
var atom = NewError(nil)
|
||||
var err1 = errors.New("err1")
|
||||
var err2 = errors.New("err2")
|
||||
return func() {
|
||||
atom.Load()
|
||||
atom.Store(err1)
|
||||
atom.Load()
|
||||
atom.Store(err2)
|
||||
atom.Load()
|
||||
atom.Store(nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user