Packages

c

zio.internal.impls

OneElementConcurrentQueue

final class OneElementConcurrentQueue[A] extends MutableConcurrentQueue[A] with Serializable

This is a specialized implementation of MutableConcurrentQueue of capacity 1. Since capacity 1 queues are by default used under the hood in Streams as intermediate resource they should be very cheap to create and throw away. Hence this queue is optimized (unlike RingBuffer*) for a very small footprint, while still being plenty fast.

Allocating an object takes only 24 bytes + 8+ bytes in long adder (so 32+ bytes total), which is 15x less than the smallest RingBuffer.

zio.internal.impls.OneElementConcurrentQueue object internals: OFFSET SIZE TYPE DESCRIPTION 0 4 (object header) 4 4 (object header) 8 4 (object header) 12 4 int OneElementConcurrentQueue.capacity 16 4 java.util.concurrent.atomic.AtomicReference OneElementConcurrentQueue.ref 20 4 java.util.concurrent.atomic.LongAdder OneElementConcurrentQueue.deqAdder Instance size: 24 bytes Space losses: 0 bytes internal + 0 bytes external = 0 bytes total

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OneElementConcurrentQueue
  2. Serializable
  3. MutableConcurrentQueue
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OneElementConcurrentQueue()

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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. final val capacity: Int(1)

    The maximum number of elements that a queue can hold.

    The maximum number of elements that a queue can hold.

    Definition Classes
    OneElementConcurrentQueueMutableConcurrentQueue
    Note

    that unbounded queues can still implement this interface with capacity = MAX_INT.

  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. def dequeuedCount(): Long

    returns

    the number of elements that have ever been taken from the queue.

    Definition Classes
    OneElementConcurrentQueueMutableConcurrentQueue
    Note

    if you know how much time the queue is alive, you can calculate the rate at which elements are being dequeued.

  8. def enqueuedCount(): Long

    returns

    the number of elements that have ever been added to the queue.

    Definition Classes
    OneElementConcurrentQueueMutableConcurrentQueue
    Note

    that scala.Long is used here, since scala.Int will be overflowed really quickly for busy queues.

    ,

    if you know how much time the queue is alive, you can calculate the rate at which elements are being enqueued.

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def isEmpty(): Boolean
  15. def isFull(): Boolean
  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
    Annotations
    @native()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. def offer(a: A): Boolean

    A non-blocking enqueue.

    A non-blocking enqueue.

    returns

    whether the enqueue was successful or not.

    Definition Classes
    OneElementConcurrentQueueMutableConcurrentQueue
  21. def poll(default: A): A

    A non-blocking dequeue.

    A non-blocking dequeue.

    returns

    either an element from the queue, or the default param.

    Definition Classes
    OneElementConcurrentQueueMutableConcurrentQueue
    Note

    that if there's no meaningful default for your type, you can always use poll(null). Not the best, but reasonable price to pay for lower heap churn from not using scala.Option here.

  22. def size(): Int

    returns

    the current number of elements inside the queue.

    Definition Classes
    OneElementConcurrentQueueMutableConcurrentQueue
    Note

    that this method can be non-atomic and return the approximate number in a concurrent setting.

  23. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  24. def toString(): String
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()

Inherited from Serializable

Inherited from MutableConcurrentQueue[A]

Inherited from AnyRef

Inherited from Any

Ungrouped