Make counters atomic

This commit is contained in:
Aaron L 2016-08-14 02:31:51 -07:00
parent 522375f422
commit ff981ee885

View file

@ -6,6 +6,7 @@ import (
"regexp"
"sort"
"strconv"
"sync/atomic"
"time"
null "gopkg.in/nullbio/null.v4"
@ -36,14 +37,12 @@ var (
rgxValidTime = regexp.MustCompile(`[2-9]+`)
)
type seed int
type seed int64
var sd = new(seed)
func (s *seed) nextInt() int {
nextInt := int(*s)
*s++
return nextInt
return int(atomic.AddInt64((*int64)(s), 1))
}
// RandomizeStruct takes an object and fills it with random data.