or in another way: are there correct uses for mutable messages?
The use case I come across is that I want to process objects that are mostly of type
Map<String,List<String>>
A typical processing that an actor will do is to read or write some of the map fields. A condensed example is (excluding nulltests, etc.)
map.get("somekey").add("new value");
My guess is that keeping this immutable in Scala would be trivial using the appropriate collection types. In Java, this will require a switch to an additional class library.
But: after reading the Akka docs, I found that sending a message introduces a “before” relationship between the last access of the sender and the first access of the receiving actor. Therefore, if mapit is not unchanged, however, the sender should see all the data.
Suppose I can make sure that the sender never touches mapagain after sending it, is there any other problem with accessing data on this subject?
source
share