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 f974188 commit 3cf7507
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: test
strategy:
matrix:
go: ["1.19.x", "1.22.x", "1.23.x"]
go: ["1.22.x"]
runs-on: macos-latest
steps:
- name: Setup Go
Expand All @@ -28,5 +28,5 @@ jobs:
- name: Test
run: go test ./... -run=TestNode_ -count=1

- name: Bench
run: go test -run='^$' -bench BenchmarkNode_ ./... -timeout=0
# - name: Bench
# run: go test -run='^$' -bench BenchmarkNode_ ./... -timeout=0
7 changes: 4 additions & 3 deletions seqlock/seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package node

import (
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
Expand All @@ -26,19 +27,19 @@ type Node[K comparable, V any] struct {
lock atomic.Uint32
}

var q sync.Mutex

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

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

0 comments on commit 3cf7507

Please sign in to comment.