diff options
author | n1t0r <git@n1t0r.com> | 2023-04-21 16:49:50 +1000 |
---|---|---|
committer | n1t0r <git@n1t0r.com> | 2023-04-21 16:49:50 +1000 |
commit | 6fc264eb52036ee6011d091d9ecdfa52923d6561 (patch) | |
tree | ce246f4ddda0eb38b084ce9024d6b13f8b096434 | |
parent | c1794294b4c7606036ea9f4e36a8a8440aa57f08 (diff) | |
download | steady-6fc264eb52036ee6011d091d9ecdfa52923d6561.tar.gz steady-6fc264eb52036ee6011d091d9ecdfa52923d6561.tar.bz2 steady-6fc264eb52036ee6011d091d9ecdfa52923d6561.zip |
Add function to return the number of keys currently active.
-rw-r--r-- | queue.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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) |