Skip to content

Instantly share code, notes, and snippets.

@collinvandyck
Created June 22, 2011 15:41
Show Gist options
  • Select an option

  • Save collinvandyck/1040370 to your computer and use it in GitHub Desktop.

Select an option

Save collinvandyck/1040370 to your computer and use it in GitHub Desktop.
import java.util.concurrent.BlockingQueue
import collection.JavaConversions
object Drainer {
def drain[T](queue: BlockingQueue[T], max: Option[Int] = None) : Seq[T] = {
val arrayList = new java.util.ArrayList[T]
queue.drainTo(arrayList, max.getOrElse(queue.size()))
JavaConversions.JListWrapper(arrayList)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment