Queue and mailbox

A mailbox is a built-in class around a queue that uses semaphores to control access to the ends of a queue. A mailbox only has FIFO element ordering whereas you can access the head, tail, or middle elements of a queue.

You typically use a mailbox when there are multiple threads reading and writing data and you need the atomic test-and-set operation of semaphore to know when the mailbox is full or empty.

In the UVM, we use a TLM FIFO which is another wrapper around a mailbox. See How TLM Works | Advanced UVM | UVM/OVM Verification Methodology | Verification Academy