Hi, You can use the immutable builder pattern to get the same effect you're after.
As for the memory visibility, The "why" is because it's very useful (and needed even for immutable data, if not properly constructed). The "how" is we use memory fences to assure that the CPU is not allowed to take any shortcuts at the right places. On Tue, Oct 6, 2015 at 10:24 AM, <[email protected]> wrote: > I know but sometimes I need this kind of modifiable message. For example > when the purpose of my actor is to compete the "missing pieces of > something" ( I think I saw such designs in akka books or was it the Rolands > coursera webcrawler example) > May I ask why it is assured to work? Does the akka dispatcher call a > synchronize monitor behind the scenes to ensure field visibility? > > Am Dienstag, 6. Oktober 2015 10:11:54 UTC+2 schrieb √: >> >> Hi John, >> >> yes it will work, but keep in mind that it is *highly* discouraged to >> send mutable messages not only because it won't work across JVMs but also >> because nothing prevents you for accidental aliasing it. >> >> On Tue, Oct 6, 2015 at 9:46 AM, <[email protected]> wrote: >> >>> Hi, >>> please see the code at http://pastebin.com/L0WiXTJU >>> >>> Does Akka garantee that changes to the ArrayList "theList" will always >>> been seen by ExampleActor? <http://pastebin.com/L0WiXTJU> >>> >>> Or asked differently does the rule from >>> http://doc.akka.io/docs/akka/2.4.0/general/jmm.html >>> >>> *"The actor send rule:* the send of the message to an actor happens >>>> before the receive of that message by the same actor" >>> >>> >>> ensure that my ExampleActor logic works? >>> <http://pastebin.com/L0WiXTJU> >>> >>> >>> -- >>> >>>>>>>>>> Read the docs: http://akka.io/docs/ >>> >>>>>>>>>> Check the FAQ: >>> http://doc.akka.io/docs/akka/current/additional/faq.html >>> >>>>>>>>>> Search the archives: >>> https://groups.google.com/group/akka-user >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "Akka User List" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/akka-user. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Cheers, >> √ >> > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ > >>>>>>>>>> Check the FAQ: > http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > --- > You received this message because you are subscribed to the Google Groups > "Akka User List" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- Cheers, √ -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
