concurrency - Synchronized, wait and notify in Akka -


i'd ask thing. have 1 "rec" actor , more "sen actors". first 1 has list of messages must forwarded , senders actors keep sending messages receiver.

something this:

class rec (frw: actor) extends actor {     val mylist = nil;     def act =     {             case "start" => while(true) {/*extract first number , send frw*/} //i must use new actor if want keep reading messages             case => mylist+=i; //should use "synchronize" here (i'm extracting elements other actor after all)?     } }  class sen (rcv: actor) extends actor {     var i=100;     def act =     {             case "start" => while(i>0) {i+=1; rcv ! i;}     } } 

my problem rec must forward 1 message @ time, must save messages in list. there way improve rec actor? don't while(true), can't extract first number whenever receive message (messages stay in long in list). should use synchronized/wait/notify or there better akka? thank , sorry bad english.

according code not need rec actor @ all. achieve same result if send messages sen frw directly.

you have rememeber akka actors process messages sequentially 1 after another. messages sen arrive frw 1 message @ time if send them directly sen frw.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -