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 c1fd819 commit 51ee802
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions seqlock/seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package node

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

var q sync.Mutex
var l atomic.Uint32

func (n *Node[K, V]) Value() V {
for {
seq := n.lock.Load()
q.TryLock()
if seq&1 != 0 {
runtime.Gosched()
continue
}

t := q.TryLock()
value := n.value
if t {
q.Unlock()
}

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

0 comments on commit 51ee802

Please sign in to comment.