title: Using getOrElseUpdate of TrieMap in Scala
body: <p>I am using the <code>getOrElseUpdate</code> method of <code>scala.collection.concurrent.TrieMap</code> (from <code>2.11.6</code>)</p>
  
  <pre><code> // simplified for clarity
  
   val trie = new TrieMap[Int, Future[String]]
  
   def foo(): String = ... // a very long process
  
   val fut: Future[String] = trie.getOrElseUpdate(id, Future(foo()))
  </code></pre>
  
  <p>As I understand, if I invoke the <code>getOrElseUpdate</code> in multiple threads without any synchronization the <code>foo</code> is invoked just <em>once</em>. </p>
  
  <p>Is it correct ?</p>