diff options
author | 2022-03-08 11:56:53 +0000 | |
---|---|---|
committer | 2022-03-08 12:56:53 +0100 | |
commit | b8879ac68a30e8bccd1c96cc4630da791d8996c4 (patch) | |
tree | 77adeeaf2456610b771d9df8dc38207014215aea /vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go | |
parent | [performance] Database optimizations (#419) (diff) | |
download | gotosocial-b8879ac68a30e8bccd1c96cc4630da791d8996c4.tar.xz |
[dependencies] update go-store, go-mutexes (#422)
* update go-store, go-mutexes
Signed-off-by: kim <grufwub@gmail.com>
* update vendored code
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go b/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go index 2e7b8f802..03bf0e389 100644 --- a/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go +++ b/vendor/codeberg.org/gruf/go-mutexes/mutex_timeout.go @@ -97,7 +97,9 @@ func mutexTimeout(d time.Duration, unlock func(), fn func()) func() { // timerPool is the global &timer{} pool. var timerPool = sync.Pool{ New: func() interface{} { - return newtimer() + t := time.NewTimer(time.Minute) + t.Stop() + return &timer{t: t, c: make(chan struct{})} }, } @@ -107,13 +109,6 @@ type timer struct { c chan struct{} } -// newtimer returns a new timer instance. -func newtimer() *timer { - t := time.NewTimer(time.Minute) - t.Stop() - return &timer{t: t, c: make(chan struct{})} -} - // Start will start the timer with duration 'd', performing 'fn' on timeout. func (t *timer) Start(d time.Duration, fn func()) { t.t.Reset(d) |