[fix] make FunctionCache thread safe
This commit is contained in:
@@ -10,7 +10,9 @@ class FunctionCache(private val xPrecision: Double, val function: (Double) -> Do
|
||||
val ceil: MutableMap.MutableEntry<Double, Double>? = values.ceilingEntry(x)
|
||||
return if (floor == null || ceil == null || ceil.key - floor.key <= xPrecision) {
|
||||
val newValue = function(x)
|
||||
values[x] = newValue
|
||||
synchronized(this) {
|
||||
values[x] = newValue
|
||||
}
|
||||
newValue
|
||||
} else {
|
||||
val x0 = floor.key
|
||||
|
||||
Reference in New Issue
Block a user