Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiling-J committed Oct 1, 2024
1 parent 12ddc7c commit e640150
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion seqlock/seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ 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
}

value := n.value

if seq == n.lock.Add(0) {
l.Add(0)
if seq == n.lock.Load() {
return value
}
}
Expand Down

0 comments on commit e640150

Please sign in to comment.