并发控制与事务

Transaction | 并发控制与事务

Memory Model | 内存模型

With the Actors implementation in Akka, there are two ways multiple threads can execute actions on shared memory:

if a message is sent to an actor (e.g. by another actor). In most cases messages are immutable, but if that message is not a properly constructed immutable object, without a “happens before” rule, it would be possible for the receiver to see partially initialized data structures and possibly even values out of thin air (longs/doubles). if an actor makes changes to its internal state while processing a message, and accesses that state while processing another message moments later. It is important to realize that with the actor model you don’t get any guarantee that the same thread will be executing the same actor for different messages. To prevent visibility and reordering problems on actors, Akka guarantees the following two “happens before” rules:

The actor send rule: the send of the message to an actor happens before the receive of that message by the same actor. The actor subsequent processing rule: processing of one message happens before processing of the next message by the same actor.

Dispatcher

STM 软件事务内存

上一页
下一页