All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.reactors.common.TransferQueue.scala Maven / Gradle / Ivy

package io.reactors
package common






class TransferQueue[T: Arrayable](val monitor: AnyRef) {
  private val queue = new UnrolledRing[T]

  def isEmpty: Boolean = monitor.synchronized {
    queue.isEmpty
  }

  def waitUntilDequeue(): T = monitor.synchronized {
    while (queue.isEmpty) monitor.wait()
    queue.dequeue()
  }

  def enqueue(x: T): Unit = monitor.synchronized {
    queue.enqueue(x)
    monitor.notifyAll()
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy