mot.queue

LinkedBlockingMultiQueue

Related Docs: object LinkedBlockingMultiQueue | package queue

class LinkedBlockingMultiQueue[A, E >: Null] extends Pollable[E]

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 or Queue interfaces. The traditional queue interface is split in the traits: Offerable and Pollable.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. LinkedBlockingMultiQueue
  2. Pollable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new LinkedBlockingMultiQueue(defaultCapacity: Int = Int.MaxValue)

Type Members

  1. class SubQueue extends Offerable[E]

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. def addSubQueue(key: A, capacity: Int = defaultCapacity, priority: Int = 100): SubQueue

    Add a sub queue.

    Add a sub queue.

    priority

    the queue priority, a lower number means higher priority

  5. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. val defaultCapacity: Int

  8. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  12. def getOrCreateSubQueue(key: A): (SubQueue, Boolean)

  13. def getSubQueue(key: A): Option[SubQueue]

  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  15. def isEmpty(): Boolean

    Definition Classes
    LinkedBlockingMultiQueuePollable
  16. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Definition Classes
    AnyRef
  19. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  20. def poll(timeout: Long, unit: TimeUnit): E

    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.

    timeout

    how long to wait before giving up, in units of unit

    unit

    a TimeUnit determining how to interpret the timeout parameter

    returns

    the head of this queue, or null if the specified waiting time elapses before an element is available

    Definition Classes
    LinkedBlockingMultiQueuePollable
  21. def pollWithRemaining(timeout: Long, unit: TimeUnit): (E, Int)

    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).

    timeout

    how long to wait before giving up, in units of unit

    unit

    a TimeUnit determining how to interpret the timeout parameter

    returns

    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.

    Definition Classes
    LinkedBlockingMultiQueuePollable
  22. def removeSubQueue(key: A): Option[SubQueue]

  23. def subQueues(): Map[A, SubQueue]

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  25. def toString(): String

    Definition Classes
    AnyRef → Any
  26. def totalSize(): Int

  27. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Pollable[E]

Inherited from AnyRef

Inherited from Any

Ungrouped