diff options
author | Matt Joiner <anacrolix@gmail.com> | 2020-10-02 17:33:20 +1000 |
---|---|---|
committer | Matt Joiner <anacrolix@gmail.com> | 2020-10-02 17:33:20 +1000 |
commit | 877bf18b7e26a4ee958fa4839c185c87fbcd7560 (patch) | |
tree | 264e499836cd8bf54736a7795a441c942d538b8a /retry.go | |
parent | Add benchmark utils (diff) | |
download | stm-877bf18b7e26a4ee958fa4839c185c87fbcd7560.tar.gz stm-877bf18b7e26a4ee958fa4839c185c87fbcd7560.tar.xz |
Add retry profiling
Diffstat (limited to 'retry.go')
-rw-r--r-- | retry.go | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1,14 +1,20 @@ package stm -// Retry is a sentinel value. When thrown via panic, it indicates that a +import ( + "runtime/pprof" +) + +var retries = pprof.NewProfile("stmRetries") + +// retry is a sentinel value. When thrown via panic, it indicates that a // transaction should be retried. -const Retry = "retry" +var retry = &struct{}{} // catchRetry returns true if fn calls tx.Retry. -func catchRetry(fn Operation, tx *Tx) (result interface{}, retry bool) { +func catchRetry(fn Operation, tx *Tx) (result interface{}, gotRetry bool) { defer func() { - if r := recover(); r == Retry { - retry = true + if r := recover(); r == retry { + gotRetry = true } else if r != nil { panic(r) } |