A cache that is a hybrid of the Memoizer in Listing 5.19 in Java Concurrency in Practice and https://www.bionicspirit.com/blog/2012/07/02/love-scala.html.
A cache that is a hybrid of the Memoizer in Listing 5.19 in Java Concurrency in Practice and https://www.bionicspirit.com/blog/2012/07/02/love-scala.html. Makes sure to put a Promise of the memoized value into the cache only if it's not already there. Then only compute the actual value (in a Future) and complete the Promise with the Future only if the promise was successfully inserted atomically. Otherwise, another promise was snuck in so use the Future associated with that Promise.
val cache = new NoEvictionCache val slow = () => {Thread.sleep(5000); println("executing slow()"); 1} val t1 = System.nanoTime // Start the clock val futures = Seq( // Returns immediately (non-blocking) cache("one"){slow()}, // Only execute slow() once. cache("one"){slow()}) val a = Future.fold(futures)(0)(_+_) // Returns immediately (non-blocking) val t2 = System.nanoTime println("Runtime for setup: " + (1.0e-9*(t2-t1)).toFloat) // Prints: "Runtime for setup: 0.001041" a.onSuccess{ case i => val t3 = System.nanoTime // Determine elapsed time. println(i + ", runtime: " + (1.0e-9*(t3-t1)).toFloat) // Prints: "2, runtime: 5.002082" }
This package name is kept to eHarmony compatibility.
A facade layer on top of the scala reflection APIs to avoid bugs currently in the TypeTag implementation.
A facade layer on top of the scala reflection APIs to avoid bugs currently in the TypeTag implementation.
Because of SI-7555, we want to insulate ourselves from reflection bugs. We do want to make the switch painless when we finally go from scala.reflect.Manifest to scala.reflect.runtime.universe.TypeTag based reflection. To accomplish this, we add a layer of indirection and later, we'll only have to modify the facade assuming that all of the code using reflection refers to the facade. Once everything has settled down on the scala reflection landscape, we'll refer directly to the reflection APIs.