Programming: Queues

From wikinotes
Revision as of 02:26, 7 August 2022 by Will (talk | contribs) (Created page with "= Blocking Queue = <blockquote> Interface between producers, and consumers of data. A Generic FIFO Array/List in shared memory,<br> with put/take methods protected by a lock.<br> Empowers the Producer/Consumer pattern. * If the queue has a fixed-size, <code>put</code> 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 </blockquote><!-- Blocking Queue --> = Deque = <blockquote> A d...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.