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 33dc359 commit 34a6741
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions seqlock/seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type Node[K comparable, V any] struct {
lock atomic.Uint32
}

var l atomic.Uint32

func (n *Node[K, V]) Value() V {
for {
seq := n.lock.Load()
Expand All @@ -36,10 +34,16 @@ func (n *Node[K, V]) Value() V {
continue
}

value := n.value
var value V

if seq > 1 {
value = n.value
} else {
value = n.value
}

l.CompareAndSwap(0, 0)
if seq == n.lock.Load() {
seq2 := n.lock.Load()
if seq == seq2 {
return value
}
}
Expand Down

0 comments on commit 34a6741

Please sign in to comment.