aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2019-11-04 18:45:41 +1100
committerMatt Joiner <anacrolix@gmail.com>2019-11-04 18:45:41 +1100
commit35df7f259b6300abd052f166b38100947c50fece (patch)
tree6ab726ace9daea73891c107866c704eca4576e0c
parentUse atomic.Value for Var state (diff)
downloadstm-35df7f259b6300abd052f166b38100947c50fece.tar.gz
stm-35df7f259b6300abd052f166b38100947c50fece.tar.xz
Fix TestDecrement
With only a single cpu it would spin endlessly without a synchronization point (since changing AtomicGet to use atomics).
-rw-r--r--stm_test.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/stm_test.go b/stm_test.go
index 527e480..28f56ec 100644
--- a/stm_test.go
+++ b/stm_test.go
@@ -15,12 +15,10 @@ func TestDecrement(t *testing.T) {
}
done := make(chan struct{})
go func() {
- for {
- if AtomicGet(x).(int) == 500 {
- break
- }
- }
- done <- struct{}{}
+ Atomically(func(tx *Tx) {
+ tx.Assert(tx.Get(x) == 500)
+ })
+ close(done)
}()
select {
case <-done: