Jul
27
comment Updating immutable map as the side effect of getOrElse
@dk14 Right, that makes sense. I don't care about that, it's what I meant by "Since it's a memoization cache, the values are deterministic, so I don't care which thread gets to update the var first."
Jul
27
comment Updating immutable map as the side effect of getOrElse
Am I reading the JVM memory model wrong? Looks like reference assignments are atomic. "Writes to and reads of references are always atomic, regardless of whether they are implemented as 32-bit or 64-bit values." from docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.7
Jul
27
comment Updating immutable map as the side effect of getOrElse
Assuming reassigning the var itself is atomic, and the values I put in the map are deterministic, what kind of problems could I have? Or is reassigning the var not atomic?
Jul
27
comment Updating immutable map as the side effect of getOrElse
For thread safety. Since it's a memoization cache, the values are deterministic, so I don't care which thread gets to update the var first. On the other hand I've had actual problems with multithreaded access to a mutable map.
Jul
27
comment Updating immutable map as the side effect of getOrElse
"To do this with an immutable map, you'll need to work with a var and replace that var with the new Map" -- sure, that's what I'm doing with immutableMap += key -> value
Jul
27
asked Updating immutable map as the side effect of getOrElse
Jul
19
awarded Popular Question
Jul
8
asked Government bonds ETF
Jun
30
awarded Popular Question
Jun
4
awarded Notable Question
Mar
16
awarded Nice Question
Jan
23
awarded Notable Question
Jan
22
comment Why do game engines convert models to triangles compared to keeping it as four side polygon
@newbiez Three vertexes always define a single plane. A sphere is made of different triangles; two adjacent triangles representing a patch of the surface of the sphere share two vertexes, but they're not on the same plane. This image may make things clearer: cse.csusb.edu/tongyu/courses/cs420/images/icos.jpg
Dec
19
awarded Yearling
Dec
11
awarded Yearling
Dec
11
awarded Yearling
Dec
7
awarded Notable Question
Dec
5
asked YQL: Finace sometimes returns quotes in cents
Dec
2
awarded Popular Question
Nov
20
awarded Yearling
1 2 3 4 5