diff options
Diffstat (limited to 'src/library/scala/ref/ReferenceQueue.scala')
-rw-r--r-- | src/library/scala/ref/ReferenceQueue.scala | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/library/scala/ref/ReferenceQueue.scala b/src/library/scala/ref/ReferenceQueue.scala index c7fae4eb79..5ef74bbc95 100644 --- a/src/library/scala/ref/ReferenceQueue.scala +++ b/src/library/scala/ref/ReferenceQueue.scala @@ -10,30 +10,23 @@ package scala.ref -import scala.collection.mutable.HashMap - /** - * @author Sean McDirmid, Philipp Haller + * @author Sean McDirmid + * @author Philipp Haller */ class ReferenceQueue[+T <: AnyRef] { + private[ref] val underlying: java.lang.ref.ReferenceQueue[_ <: T] = new java.lang.ref.ReferenceQueue[T] override def toString = underlying.toString - protected def Wrapper(jref: java.lang.ref.Reference[_]) = jref match { - case null => None - case ref => - val refWrapper = wrappers(ref) - wrappers -= ref - Some(refWrapper.asInstanceOf[Reference[T]]) - } + protected def Wrapper(jref: java.lang.ref.Reference[_]): Option[Reference[T]] = + jref match { + case null => None + case ref => Some(ref.asInstanceOf[ReferenceWithWrapper[T]].wrapper) + } def poll: Option[Reference[T]] = Wrapper(underlying.poll) def remove: Option[Reference[T]] = Wrapper(underlying.remove) def remove(timeout: Long): Option[Reference[T]] = Wrapper(underlying.remove(timeout)) - protected val wrappers = new HashMap[java.lang.ref.Reference[_], - ReferenceWrapper[_ <: AnyRef]] - def register(ref: ReferenceWrapper[_ <: AnyRef]) { - wrappers += ((ref.underlying, ref)) - } } |