or put another way: are there proper uses of mutable messages?
The use case I am facing is that I want to process objects which basically are of type
Map<String,List<String>>
The typical processing an actor would do is to read or write some of the fields of the map. A condensed example is (leaving out null
-tests etc.)
map.get("somekey").add("new value");
My hunch is that keeping this immutable in Scala would be trivial by using the respective collection types. In Java it would require to go for some additional class library.
But: reading the Akka docs, I find that sending a message introduces a happens-before relation between the last access of the sender and the first access of the receiving actor. So if the map
is not immutable, nevertheless the sender should see all data.
Suppose I can make sure that the sender will never touch the map
again once it is send, is there any other problem to expect with regards to threaded data access to this map?