Synchronizing on function parameter for multithreaded memoization
问题 My core question is: how can I implement synchronization in a method on the combination of the object instance and the method parameter? Here are the details of my situation. I'm using the following code to implement memoization, adapted from this answer: /** * Memoizes a unary function * @param f the function to memoize * @tparam T the argument type * @tparam R the result type */ class Memoized[-T, +R](f: T => R) extends (T => R) { import scala.collection.mutable private[this] val cache =