summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-mutexes/pool.go
diff options
context:
space:
mode:
authorLibravatar Terin Stock <terinjokes@gmail.com>2022-04-26 20:30:25 -0700
committerLibravatar Terin Stock <terinjokes@gmail.com>2023-01-31 15:16:42 +0100
commit83b4c9ebc87d0fddf4e638f13e3af1483912e3a5 (patch)
tree47840b84c0fd3cb226eab2ecb3dbce0617163406 /vendor/codeberg.org/gruf/go-mutexes/pool.go
parent[chore] update URLs to forked source (diff)
downloadgotosocial-83b4c9ebc87d0fddf4e638f13e3af1483912e3a5.tar.xz
[chore] remove vendor
Diffstat (limited to 'vendor/codeberg.org/gruf/go-mutexes/pool.go')
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/pool.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/vendor/codeberg.org/gruf/go-mutexes/pool.go b/vendor/codeberg.org/gruf/go-mutexes/pool.go
deleted file mode 100644
index 135e2c117..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/pool.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package mutexes
-
-// pool is a very simply memory pool.
-type pool struct {
- current []interface{}
- victim []interface{}
- alloc func() interface{}
-}
-
-// Acquire will returns a sync.RWMutex from pool (or alloc new).
-func (p *pool) Acquire() interface{} {
- // First try the current queue
- if l := len(p.current) - 1; l >= 0 {
- v := p.current[l]
- p.current = p.current[:l]
- return v
- }
-
- // Next try the victim queue.
- if l := len(p.victim) - 1; l >= 0 {
- v := p.victim[l]
- p.victim = p.victim[:l]
- return v
- }
-
- // Lastly, alloc new.
- return p.alloc()
-}
-
-// Release places a sync.RWMutex back in the pool.
-func (p *pool) Release(v interface{}) {
- p.current = append(p.current, v)
-}
-
-// GC will clear out unused entries from the pool.
-func (p *pool) GC() {
- current := p.current
- p.current = nil
- p.victim = current
-}