That is how I've implemented it finally. Just store messages and restore them when the result would become clear. The actor performs some data management, so it should have confidence in own state before it could proceed further messages.
But reducing actor activity to just message shuffling is is a little bit discomfortable. Keeping messages in the common mailbox looks more consistent but also more hazardous: it brings possibility of buffer overrun to the mailbox instead of just an actor. All the worries are from akka lacking built-in backpressure control. So you need to reinvent it to some extent. On Tuesday, February 21, 2017 at 3:57:05 PM UTC+3, Justin du coeur wrote: > > On Tue, Feb 21, 2017 at 7:19 AM, Alan Burlison <alan.b...@gmail.com > <javascript:>> wrote: > >> On 21/02/2017 12:12, Viktor Klang wrote: >> >> http://doc.akka.io/docs/akka/2.4/scala/actors.html#Stash >>> >> >> Ahah! I'd seen stash in the docs and not really come up with an case >> (other than become/become) where it would be useful, and then forgotten >> about it. I'm still not clear how it would help in this scenario though? > > > As I understand it, you want your parent to "wait" until it has collected > all the info from the children before it moves on to doing something else. > (Forgive me if I'm misunderstanding your use case -- it isn't spelled out > in great detail above.) > > The Akka-idiomatic way to do this is for the parent to do something like: > > -- Send out the jobs to the children > -- become() into a different receive processor > -- In this new processor, everything *other* than the responses from the > children get stash()ed -- that is, you save them away for later > -- Once you have accumulated all of the child responses (or timed out -- > it is often adviseable to have a timeout scheduled), send out the > aggregated response. Then unstash() everything that's been stored up, and > become() back to your original state. > > Essentially, instead of waiting/blocking, you shunt everything else aside > (queueing it, essentially) until you're ready to handle it. The effect is > largely the same, but without tying up threads. > -- >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.