Introduce an atomic type-safe wrapper around error type. (#42)

This commit is contained in:
alexeypavlenko
2018-09-27 19:07:59 +03:00
committed by Prashant Varanasi
parent ca68046243
commit bb9a8edc0f
3 changed files with 126 additions and 0 deletions

View File

@@ -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)
}
}