summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-mutexes/map_pool.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-10-31 11:12:22 +0000
committerLibravatar GitHub <noreply@github.com>2023-10-31 11:12:22 +0000
commitce71a5a7902963538fc54583588850563f6746cc (patch)
tree3e869eba6d25d2db5fe81184ffee595e451b3147 /vendor/codeberg.org/gruf/go-mutexes/map_pool.go
parent[bugfix] Relax `Mention` parsing, allowing either href or name (#2320) (diff)
downloadgotosocial-ce71a5a7902963538fc54583588850563f6746cc.tar.xz
[feature] add per-uri dereferencer locks (#2291)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-mutexes/map_pool.go')
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/map_pool.go39
1 files changed, 0 insertions, 39 deletions
diff --git a/vendor/codeberg.org/gruf/go-mutexes/map_pool.go b/vendor/codeberg.org/gruf/go-mutexes/map_pool.go
deleted file mode 100644
index 450e0bc06..000000000
--- a/vendor/codeberg.org/gruf/go-mutexes/map_pool.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package mutexes
-
-// pool is a very simply memory pool.
-type pool struct {
- current []*rwmutex
- victim []*rwmutex
-}
-
-// Acquire will returns a rwmutex from pool (or alloc new).
-func (p *pool) Acquire() *rwmutex {
- // First try the current queue
- if l := len(p.current) - 1; l >= 0 {
- mu := p.current[l]
- p.current = p.current[:l]
- return mu
- }
-
- // Next try the victim queue.
- if l := len(p.victim) - 1; l >= 0 {
- mu := p.victim[l]
- p.victim = p.victim[:l]
- return mu
- }
-
- // Lastly, alloc new.
- return &rwmutex{}
-}
-
-// Release places a sync.RWMutex back in the pool.
-func (p *pool) Release(mu *rwmutex) {
- p.current = append(p.current, mu)
-}
-
-// GC will clear out unused entries from the pool.
-func (p *pool) GC() {
- current := p.current
- p.current = nil
- p.victim = current
-}