aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukechampine <luke.champine@gmail.com>2016-03-31 02:04:31 -0400
committerlukechampine <luke.champine@gmail.com>2016-03-31 02:04:31 -0400
commita18521271669148081771cbcf48194742d129e68 (patch)
treec0c02e2c8ac08b9d7835eed2c96c447306ddf822
parentupdate README with examples + benchmarks (diff)
downloadstm-a18521271669148081771cbcf48194742d129e68.tar.gz
stm-a18521271669148081771cbcf48194742d129e68.tar.xz
only broadcast when at least one Var changed
-rw-r--r--stm.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/stm.go b/stm.go
index 11692f4..f9c09a7 100644
--- a/stm.go
+++ b/stm.go
@@ -219,9 +219,11 @@ retry:
globalLock.Unlock()
goto retry
}
- // commit the write log
- tx.commit()
- globalCond.Broadcast()
+ // commit the write log and broadcast that variables have changed
+ if len(tx.writes) > 0 {
+ tx.commit()
+ globalCond.Broadcast()
+ }
globalLock.Unlock()
}