On Tue, Feb 21, 2017 at 7:19 AM, Alan Burlison <[email protected]>
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to