class TwoPhasePriorityAccumulator[A, B] extends AnyRef
A container with two phases for items with priorities:
- In the accumulation phase, items can be added with a priority via TwoPhasePriorityAccumulator.accumulate.
- In the draining phase, items can be removed in priority order via TwoPhasePriorityAccumulator.drain. The order of items with equal priority is unspecified.
TwoPhasePriorityAccumulator.stopAccumulating switches from the accumulation phase to the draining phase. Items can be removed from the container via the handle returned by TwoPhasePriorityAccumulator.accumulate.
- A
The type of items to accumulate
- B
The type of labels for the draining phase
- Alphabetic
- By Inheritance
- TwoPhasePriorityAccumulator
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def accumulate(item: A, priority: Priority): Either[B, ItemHandle]
Adds the given item with the given priority, if this container is still in the accumulation phase, and returns a handle to remove it.
Adds the given item with the given priority, if this container is still in the accumulation phase, and returns a handle to remove it. If the container is already in the draining phase, the item is not added and instead the draining phase label is returned.
The same item can be added multiple times, with the same or different priorities, and the container then holds it multiple times. Accordingly, the item will appear as many times during draining as it was added and not removed, unless it has become obsolete.
- def afterRegistration(): Unit
Hook for testing interesting interleavings
Hook for testing interesting interleavings
- Attributes
- protected
- Annotations
- @VisibleForTesting()
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def drain()(implicit errorLoggingContext: ErrorLoggingContext): Iterator[(A, Priority)]
Returns an iterator over the items to be drained in priority order.
Returns an iterator over the items to be drained in priority order. Lower priority values are drained first.
May only be called during the draining phase.
An item is to be drained if all of the following conditions apply:
- It was added during the accumulation phase.
- It has not yet been successfully removed via the handle.
- It has not yet been garbage-collected because it was obsolete at some point since it was added.
If called multiple times during the draining phase, each returned iterator yields only a subset of the items to be drained, respecting the priority order within the subset. All these iterators jointly return all items to be drained with their correct multiplicity.
The returned iterator is not thread-safe: it must not be used from multiple threads without explicit synchronization.
- Exceptions thrown
java.lang.IllegalStateException
if called during the accumulation phase
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def getPhase: Option[B]
Returns scala.None$ in the accumulating phase, and scala.Some$ with the label of the draining phase.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def isAccumulating: Boolean
Whether this class is still in the accumulation phase
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def stopAccumulating(b: B): Option[B]
Switches from the accumulation phase to the draining phase.
Switches from the accumulation phase to the draining phase. Only the first call to this method is effective; all subsequent calls are ignored.
- b
The label for the draining phase
- def stopAndDrain(b: B)(implicit errorLoggingContext: ErrorLoggingContext): Iterator[(A, Priority)]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])