diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index 64df28b..1513961 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -28,5 +28,5 @@ jobs: - name: Test run: go test ./... -run=TestNode_ -count=1 - - name: Bench - run: go test -run='^$' -cpu=6 -bench BenchmarkNode_ ./... -timeout=0 + # - name: Bench + # run: go test -run='^$' -cpu=6 -bench BenchmarkNode_ ./... -timeout=0 diff --git a/seqlock/seq_test.go b/seqlock/seq_test.go index 6a5c338..a497aa4 100644 --- a/seqlock/seq_test.go +++ b/seqlock/seq_test.go @@ -27,8 +27,10 @@ type Node[K comparable, V any] struct { } func (n *Node[K, V]) Value() V { + var l atomic.Uint32 for { seq := n.lock.Load() + l.Load() if seq&1 != 0 { runtime.Gosched() continue @@ -36,7 +38,8 @@ func (n *Node[K, V]) Value() V { value := n.value - if seq == n.lock.Add(0) { + l.Add(0) + if seq == n.lock.Load() { return value } }