summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-structr/item.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-10-03 15:29:41 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-10-03 15:29:41 +0200
commitff950e94bb8a2e1b3c905bdba4c44d0232704b18 (patch)
treea6aedfd6a89438f400bc20c90457552e4176f1ba /vendor/codeberg.org/gruf/go-structr/item.go
parent[chore] Use bulk updates + fewer loops in status rethreading migration (#4459) (diff)
downloadgotosocial-ff950e94bb8a2e1b3c905bdba4c44d0232704b18.tar.xz
[chore] update dependencies (#4468)
- github.com/ncruces/go-sqlite3 - codeberg.org/gruf/go-mempool - codeberg.org/gruf/go-structr (changes related on the above) * - codeberg.org/gruf/go-mutexes (changes related on the above) * * this is largely just fiddling around with package internals in structr and mutexes to rely on changes in mempool, which added a new concurrency-safe pool Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4468 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/item.go')
-rw-r--r--vendor/codeberg.org/gruf/go-structr/item.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/item.go b/vendor/codeberg.org/gruf/go-structr/item.go
index 08f054907..4c63b97c6 100644
--- a/vendor/codeberg.org/gruf/go-structr/item.go
+++ b/vendor/codeberg.org/gruf/go-structr/item.go
@@ -2,8 +2,9 @@ package structr
import (
"os"
- "sync"
"unsafe"
+
+ "codeberg.org/gruf/go-mempool"
)
type indexed_item struct {
@@ -19,17 +20,15 @@ type indexed_item struct {
indexed []*index_entry
}
-var indexed_item_pool sync.Pool
+var indexed_item_pool mempool.UnsafePool
// new_indexed_item returns a new prepared indexed_item.
func new_indexed_item() *indexed_item {
- v := indexed_item_pool.Get()
- if v == nil {
- i := new(indexed_item)
- i.elem.data = unsafe.Pointer(i)
- v = i
+ if ptr := indexed_item_pool.Get(); ptr != nil {
+ return (*indexed_item)(ptr)
}
- item := v.(*indexed_item)
+ item := new(indexed_item)
+ item.elem.data = unsafe.Pointer(item)
return item
}
@@ -43,7 +42,8 @@ func free_indexed_item(item *indexed_item) {
return
}
item.data = nil
- indexed_item_pool.Put(item)
+ ptr := unsafe.Pointer(item)
+ indexed_item_pool.Put(ptr)
}
// drop_index will drop the given index entry from item's indexed.