Hello.
As I understand code like this is quite common:
def receive = {
case r: SomeMessage =>
val fResult: Future[SomeResult] = {
for {
_ <- readSomethingFromDB()
_ = readAndWriteActorState()
_ <- writeSomethingToDB()
_ <- doSomethingElse()
} yield result
}
fResult pipeTo sender
}
In such cases it is a good idea to use Stash trait and become /
unbecome to avoid cases like this:
(request 1) readSomethingFromDB()
(request 2) readSomethingFromDB()
(request 2) readAndWriteActorState()
(request 1) readAndWriteActorState()
(request 1) writeSomethingToDB()
(request 2) writeSomethingToDB()
... etc ...
Which clearly is a race condition and almost always is not something
what programmer really wants. Still as I understand there is no
stashedPipeTo method or something like this in Akka, so every team has
to write its own version.
Am I right so far? And is there any reason not to add such a method to
Akka?
--
Best regards,
Eax Melanhovich
http://eax.me/
--
>>>>>>>>>> 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.