Created
June 22, 2011 15:41
-
-
Save collinvandyck/1040370 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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