Skip to content

Commit a7e3eb0

Browse files
committedDec 1, 2023
epp: tweak seqSource
1 parent 8ac246f commit a7e3eb0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎id.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
type seqSource struct {
1111
prefix string
12-
n uint64
12+
n atomic.Uint64
1313
}
1414

1515
func newSeqSource(prefix string) (*seqSource, error) {
@@ -27,5 +27,9 @@ func newSeqSource(prefix string) (*seqSource, error) {
2727
}
2828

2929
func (s *seqSource) ID() string {
30-
return s.prefix + strconv.FormatUint(atomic.AddUint64(&s.n, 1), 10)
30+
return s.prefix + strconv.FormatUint(s.id(), 10)
31+
}
32+
33+
func (s *seqSource) id() uint64 {
34+
return s.n.Add(1)
3135
}

0 commit comments

Comments
 (0)