1
2
3
4
5
6
Use the "Verify Solution" button to get AI feedback on your C++ code.
Your task is to implement a robust ThreadSafeQueue<T> in C++ that supports safe concurrent operations from multiple producer and consumer threads. The queue should store elements of type T.
push method should add an element to the queue safely.pop method should retrieve and remove an element from the queue. If the queue is empty, pop must block until an element becomes available.empty method should return true if the queue is empty, false otherwise, and must be thread-safe.The provided starter code contains several common concurrency-related bugs and incomplete sections. You need to identify and fix these issues to ensure the queue is fully thread-safe and behaves as expected.