diff options
author | Matt Joiner <anacrolix@gmail.com> | 2020-10-01 10:01:36 +1000 |
---|---|---|
committer | Matt Joiner <anacrolix@gmail.com> | 2020-10-01 10:01:36 +1000 |
commit | bf1dcaa4b5238aee2c520dae1a6a32840c0d659b (patch) | |
tree | dfe12826040787002bafc0e27903053a597e30ce /funcs.go | |
parent | Wake watchers until the var changes again (diff) | |
download | stm-bf1dcaa4b5238aee2c520dae1a6a32840c0d659b.tar.gz stm-bf1dcaa4b5238aee2c520dae1a6a32840c0d659b.tar.xz |
Tidy up newTx usage and recycle from WouldBlock
Diffstat (limited to 'funcs.go')
-rw-r--r-- | funcs.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -33,13 +33,19 @@ func init() { } func newTx() *Tx { - return txPool.Get().(*Tx) + tx := txPool.Get().(*Tx) + tx.tries = 0 + return tx } func WouldBlock(fn Operation) (block bool) { tx := newTx() tx.reset() _, block = catchRetry(fn, tx) + if len(tx.watching) != 0 { + panic("shouldn't have installed any watchers") + } + tx.recycle() return } @@ -48,7 +54,6 @@ func Atomically(op Operation) interface{} { expvars.Add("atomically", 1) // run the transaction tx := newTx() - tx.tries = 0 retry: tx.tries++ tx.reset() |