On 05.02.15 16:38, Roland Kuhn wrote:
Hi Martin,

I’m hesitant to do this since this method is not “safe” from a message ordering standpoint: if the unstashed message ends up being re-stashed (due to faulty logic) then it will go from the head to the tail of the stash. It does seem like an “expert feature” to me.

As long as the documentation is clear about that, why not just let the user decide if it should be used or not? You have potential re-ordering issues also in another place of Akka's public API: AtLeastOnceDelivery, for example.


The context I considered this is (very recently) is Akka Typed: I have not yet figured out how or even if to provide this feature. The only difference between The Stash and a normal linear buffer within the actor itself is that the former is retained across a restart while the latter is not. Since the Actor obviously was faulty (otherwise there would be no restart), how much can we trust the stash? If the stashing and the function of the Actor are not related, then we can easily express these two in separate Actors, with the stash being the parent of the real recipient.

But in this case the child has to pull the messages from the parent's internal buffer when ready for the next message. Otherwise, you'd introduce ordering issues again. We had this pattern implemented in early development stages of akka-persistence but then switched to unstash() for efficiency reasons (and because it was a lot simpler).

Furthermore, I don't think my use case is that uncommon:

- actor state machine with states s1 and s2
- if in s1, process message and switch to s2
- if in s2, stash message(s) and do some async processing
- if async processing completes, switch back to s1 and process next message

Using unstashAll() in the last step copies the all stashed messages back, only for processing the next one and redundantly stashing the others -> this is O(n*n) where n = number of messages in the mailbox. This is very painful for a large number of messages in the mailbox. Making unstash() public would be a simple and IMO clean solution to this problem.


Regards,

Roland

5 feb 2015 kl. 16:29 skrev Martin Krasser <[email protected] <mailto:[email protected]>>:

Hi,

does anything speak against making unstash() <https://github.com/akka/akka/blob/v2.3.9/akka-actor/src/main/scala/akka/actor/Stash.scala#L186> public (currently private[akka])? In my use case, it would help me to avoid redundantly moving messages between the stash and the actor mailbox using stash()/unstashAll().

Thanks,
Martin

--
Martin Krasser

blog:http://krasserm.github.io
code:http://github.com/krasserm
twitter:http://twitter.com/mrt1nz

--
>>>>>>>>>> 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] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



*Dr. Roland Kuhn*
/Akka Tech Lead/
Typesafe <http://typesafe.com/> – Reactive apps on the JVM.
twitter: @rolandkuhn
<http://twitter.com/#%21/rolandkuhn>

--
>>>>>>>>>> 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] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

--
Martin Krasser

blog:    http://krasserm.github.io
code:    http://github.com/krasserm
twitter: http://twitter.com/mrt1nz

--
     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.

Reply via email to