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

scalapb.descriptors.ConcurrentWeakReferenceMap.scala Maven / Gradle / Ivy

package scalapb.descriptors

/** Javascript (and hence Scala.js) does not have WeakReferences and WeakHashMap, so we use a normal
  * HashMap.
  */
private[descriptors] class ConcurrentWeakReferenceMap[K, V] {
  private val underlying: collection.mutable.Map[K, V] = new collection.mutable.HashMap[K, V]()

  def getOrElseUpdate(key: K, newValue: => V): V = this.synchronized {
    underlying.getOrElseUpdate(key, newValue)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy