summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-structr/queue.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/queue.go')
-rw-r--r--vendor/codeberg.org/gruf/go-structr/queue.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/queue.go b/vendor/codeberg.org/gruf/go-structr/queue.go
index 70c18c839..91092790a 100644
--- a/vendor/codeberg.org/gruf/go-structr/queue.go
+++ b/vendor/codeberg.org/gruf/go-structr/queue.go
@@ -205,6 +205,24 @@ func (q *Queue[T]) Len() int {
return l
}
+// Debug returns debug stats about queue.
+func (q *Queue[T]) Debug() map[string]any {
+ m := make(map[string]any)
+ q.mutex.Lock()
+ m["queue"] = q.queue.len
+ indices := make(map[string]any)
+ m["indices"] = indices
+ for i := range q.indices {
+ var n uint64
+ for _, list := range q.indices[i].data {
+ n += uint64(list.len)
+ }
+ indices[q.indices[i].name] = n
+ }
+ q.mutex.Unlock()
+ return m
+}
+
func (q *Queue[T]) pop_n(n int, next func() *list_elem) []T {
if next == nil {
panic("nil fn")