Class Queue

All Implemented Interfaces:
Serializable, Cloneable, Comparable<IRubyObject>, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType, DataType
Direct Known Subclasses:
SizedQueue

public class Queue extends RubyObject implements DataType
The "Queue" class from the 'thread' library. The implementation is a kernel of Doug Lea's LinkedBlockingQueue with Ruby related tweaks: closeable (blocks out producers, no effect on consumers) and capacity adjustable (Ruby allows sized_queue.max = 123 post construction). Relevant changes noted in comments below. An optionally-bounded blocking queue based on linked nodes. This queue orders elements FIFO (first-in-first-out). The head of the queue is that element that has been on the queue the longest time. The tail of the queue is that element that has been on the queue the shortest time. New elements are inserted at the tail of the queue, and the queue retrieval operations obtain elements at the head of the queue. Linked queues typically have higher throughput than array-based queues but less predictable performance in most concurrent applications.

The optional capacity bound constructor argument serves as a way to prevent excessive queue expansion. The capacity, if unspecified, is equal to Integer.MAX_VALUE. Linked nodes are dynamically created upon each insertion unless this would bring the queue above capacity.

Since:
1.5
Author:
Doug Lea
See Also: