Add a sub queue.
Add a sub queue.
the queue priority, a lower number means higher priority
Retrieve and remove the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
Retrieve and remove the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
how long to wait before giving up, in units of unit
a TimeUnit determining how to interpret the timeout parameter
the head of this queue, or null if the specified waiting time elapses before an element is available
Retrieve and remove the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
Retrieve and remove the head of this queue, waiting up to the specified wait time if necessary for an element to become available. Also retrieve the remaining quantity of elements. This value can be used to predict whether a following poll would block (if there is a single consumer).
how long to wait before giving up, in units of unit
a TimeUnit determining how to interpret the timeout parameter
a pair, consisting of the head of this queue, or null if the specified waiting time elapses before an element is available, and the remaining quantity of elements after the returned element (if any) was removed.
An optionally-bounded blocking "multi-queue" based on linked nodes. A multi-queue is actually a set of queues that are connected at the heads and have independent tails (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 added at the tail of one of the queues, and the queue retrieval operations obtain elements from the head of some of the queues, according to a policy that is described below.
This class essentially allows a consumer to efficiently block a single thread on a set of queues, until one becomes available. The special feature is that individual queues can be enabled or disabled. A disabled queue is not considered for polling (in the event that all the queue are disabled, any blocking operation would do so trying to read, as if all the queues were empty). Elements are taken from the set of enabled queues, obeying the established priority (queues with the same priority are served round robin).
A disabled queue accepts new elements normally until it reaches the maximum capacity (if any).
Individual queues can be address, removed, enabled or disabled at any time, without any concurrency restrictions.
The optional capacity bound constructor argument serves as a way to prevent excessive queue expansion. The capacity, if unspecified, is equal to Int.MaxVaue. Linked nodes are dynamically created upon each insertion unless this would bring the queue above capacity.
Not being actually a linear queue, this class does not implement the
Collection
orQueue
interfaces. The traditional queue interface is split in the traits:Offerable
andPollable
.