aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn1t0r <git@n1t0r.com>2023-04-21 16:49:50 +1000
committern1t0r <git@n1t0r.com>2023-04-21 16:49:50 +1000
commit6fc264eb52036ee6011d091d9ecdfa52923d6561 (patch)
treece246f4ddda0eb38b084ce9024d6b13f8b096434
parentc1794294b4c7606036ea9f4e36a8a8440aa57f08 (diff)
downloadsteady-6fc264eb52036ee6011d091d9ecdfa52923d6561.tar.gz
steady-6fc264eb52036ee6011d091d9ecdfa52923d6561.tar.bz2
steady-6fc264eb52036ee6011d091d9ecdfa52923d6561.zip
Add function to return the number of keys currently active.
-rw-r--r--queue.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/queue.go b/queue.go
index a1628a5..3d61ec3 100644
--- a/queue.go
+++ b/queue.go
@@ -274,6 +274,13 @@ func (q *Queue[K]) LenKey(key K) int {
return l
}
+// LenKeys returns the current number of keys in the queue.
+func (q *Queue[K]) LenKeys() int {
+ q.partitionsMu.Lock()
+ defer q.partitionsMu.Unlock()
+ return len(q.partitions)
+}
+
// Stop makes every blocking operation return immediately with ok set to false.
func (q *Queue[K]) Stop() {
q.once.Do(q.init)