emptySlots
initialized to the capacity to represent the number of empty slots available for enqueue
operations.filledSlots
initialized to 0 to represent the number of elements available for dequeue
operations.enqueue
, acquire emptySlots
, acquire the lock, add the element to the queue, release the lock, and then release filledSlots
.dequeue
, acquire filledSlots
, acquire the lock, remove the element from the queue, release the lock, and then release emptySlots
.size
, simply return the current size of the queue.