Bounded blocking queue
This problem screams "semaphore".

Have a semaphore whose count represents the number of slots available in the queue.  Enqueuers decrement the semaphore.  Dequeuers increment it.  This effectively caps the amount of nodes in the queue to some maximum, namely the initial value of the semaphore.

Likewise you can have a different semaphore represent the number of items currently enqueued.  In this case dequeuers decrement it and enqueuers increment.  For this one, the initial value is zero.  This allows dequeuers to block until an item is available.