Added `poll()` which lets user check if the queue is empty or not

This commit is contained in:
Tristan B. Velloza Kildaire 2021-09-09 11:21:19 +02:00
parent 9c7d15dc89
commit c241d06ea9
1 changed files with 16 additions and 0 deletions

View File

@ -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