From 6c262361673ac940a8e7223228f3a7ee83356459 Mon Sep 17 00:00:00 2001 From: apio Date: Wed, 2 Aug 2023 11:55:08 +0200 Subject: [PATCH] libluna: Add CircularQueue::is_empty() --- libluna/include/luna/CircularQueue.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libluna/include/luna/CircularQueue.h b/libluna/include/luna/CircularQueue.h index 583bcbae..50317feb 100644 --- a/libluna/include/luna/CircularQueue.h +++ b/libluna/include/luna/CircularQueue.h @@ -16,6 +16,11 @@ template class CircularQueue { } + bool is_empty() + { + return m_tail.load() == m_head.load(); + } + bool try_push(const T& value) { usize current_tail = m_tail.load(MemoryOrder::Relaxed); @@ -71,6 +76,11 @@ template class DynamicCircularQueue if (m_data) free_impl(m_data); } + bool is_empty() + { + return m_tail.load() == m_head.load(); + } + Result set_size(usize size) { m_data = (T*)TRY(calloc_impl(size + 1, sizeof(T), false));