Your question is Thread-Safe Producer-Consumer Queue. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
KPMG AI solutions may process work items through concurrent producer and consumer threads. Implement a bounded, thread-safe FIFO queue without using Python's queue.Queue.
Your implementation must expose put(item, block=True, timeout=None) and get(block=True, timeout=None) operations. put waits while the queue is full, and get waits while it is empty. Both operations must wake efficiently when their required condition changes, preserve FIFO order, and prevent lost updates or corrupted state.
For automated evaluation, implement process_queue(operations, capacity). Each operation is either ["put", value] or ["get"]. The harness executes operations sequentially with non-blocking behavior: a successful put returns true, a put attempted on a full queue returns false, a successful get returns its value, and a get attempted on an empty queue returns null. The queue class itself must support blocking calls for concurrent use.
def process_queue(operations, capacity):