Programming: Queues

From wikinotes

Blocking Queue

Interface between producers, and consumers of data.

A Generic FIFO Array/List in shared memory,
with put/take methods protected by a lock.
Empowers the Producer/Consumer pattern.

  • If the queue has a fixed-size, put blocks until the queue has room for another item.
  • Setting max queue size may keep you from running out of memory in high volume producers

Deque

A double sided queue, where work can be removed from the head/tail.

If a deque is assigned to each consumer,
once a consumer has processed all of it's tasks,
it can steal work from the tail of another consumer.

These may be useful where consumers also produce work.