From c241d06ea902387522593cf47b76d4ee90515600 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Thu, 9 Sep 2021 11:21:19 +0200 Subject: [PATCH] Added `poll()` which lets user check if the queue is empty or not --- source/tristanable/queue.d | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/tristanable/queue.d b/source/tristanable/queue.d index ca99527..c2ee0c9 100644 --- a/source/tristanable/queue.d +++ b/source/tristanable/queue.d @@ -91,6 +91,22 @@ public final class Queue queueLock.unlock(); } + public bool poll() + { + /* Status */ + bool status; + + /* Lock the queue */ + queueLock.lock(); + + status = !queue.empty(); + + /* Unlock the queue */ + queueLock.unlock(); + + return status; + } + /** * Attempts to coninuously dequeue the * head of the queue