Most concurrent programs are threads passing work through queues: gateways to matchers, a feed to a strategy, a pool's task list. A thread-safe queue is a std::deque and a mutex that guards it, plus a condition variable so consumers can sleep while it is empty.
The interface needs care, because empty() followed by front() is a check-then-act race: by the time you act, another consumer may have taken the item. So a safe queue offers combined operations instead: pop() waits and removes in one call; try_pop() returns a std::optional that is empty when there is nothing, without waiting.
A queue also needs an end. close() marks it finished and wakes every waiting consumer; pop() keeps delivering what is left and returns std::nullopt only once it is closed and empty. When a consumer cannot keep up, a bounded queue either makes the producer wait or, for market data where only the latest matters, drops the oldest item.
Threads here are simulated. Your program runs on one real thread while a scheduler switches between your threads at shared reads and writes, locks, atomic operations, waits, yields and sleeps, and every test runs under 12 different schedules. The order things can happen in, races at those points and deadlocks are faithful. Real parallel speed-up and weak memory-order effects are not.
Wait, check and remove in one locked operation.