[akka-user] Question about thread safe in actor

2014-05-14 Thread Leon Ma
Hi, Assuming I have an actor which hold a map M And I will possibly do: 1, send message A to the actor 2. send message B to the actor When receiving messages, A will possibly be executed in thread 1 and B will possibly be executed in thread 2. Although A is triggered earlier than B ( sequenc

Re: [akka-user] Question about thread safe in actor

2014-05-14 Thread Konrad Malawski
Actors are thread safe inside them "by definition". The actor has one mailbox and processes the messages one by one from it. We guarantee that fields are properly visible, even if the actor jumps around threads - no need for CHM in the actor On Thu, May 15, 2014 at 7:31 AM, Leon Ma wrote: > Hi,

Re: [akka-user] Question about thread safe in actor

2014-05-14 Thread Leon Ma
By "processes the messages one by one", do you mean My message B has to be wait until message A gets processed? They can't be executed in parallel? Thanks Leon 在 2014年5月14日星期三UTC-7下午10时34分45秒,Konrad Malawski写道: > > Actors are thread safe inside them "by definition". > The actor has one mailb

Re: [akka-user] Question about thread safe in actor

2014-05-14 Thread Konrad Malawski
No. This is inherent to how the actor model is defined. Thanks to this youre safe from races inside the actor. -- Konrad 'ktoso' Malawski On 15 May 2014 07:43, "Leon Ma" wrote: > By "processes the messages one by one", do you mean My message B has to be > wait until message A gets processed? >

Re: [akka-user] Question about thread safe in actor

2014-05-15 Thread Odd Möller
If you need to enable parallel processing you could create a new child actor for each job and let the child do the actual work and then send the result back to the parent. That way you only need to do the child actor creation and reply handling in the parent actor, and thus keep the serial processi

Re: [akka-user] Question about thread safe in actor

2014-05-17 Thread Justin du coeur
On Thu, May 15, 2014 at 1:43 AM, Leon Ma wrote: > By "processes the messages one by one", do you mean My message B has to be > wait until message A gets processed? > > They can't be executed in parallel? > It's worth emphasizing -- the fact that they can't be executed in parallel is the entire *