Reputation: 153
I have read that an akka actor processes messages one after the other. Why is this?
What Im unable to wrap my head around is “Why is synchronized execution of messages the default behavior?”. I do understand that for parallel execution of mailbox messages the functions(jobs to be performed) should have 0 side effects.
Is this default akka behavior because that use cases which have absolutely independent execution and 0 side effects are a MINORITY and we usually work with jobs that need common resource.
If the design goal of scala and functional programming is 0 side effect code for which the below scenario holds true then why is this not default behavior in akka actor message processing.
Upvotes: 2
Views: 523
Reputation: 4251
My understanding is that one key point of the actor model is to make parallel programming simpler to understand (and simpler to "get right"), without hard-to-debug issues such as deadlocks.
This works because:
If the actor could process several messages in parallel, it could concurrently access its own internal state, and you would be back to having to worry about locks, synchronization, ConcurrentModificationException
s... Which would defeat the point.
Upvotes: 1