October 08, 2009
Actor Virtual MachineRex Young
Extending the OO model with Asynchronous Message Passing and Dynamic Message Binding
Rex Young can be reached at rex@fastmessenger.com. His blog is at http://www.java.net/blogs/rexyoung/.
Object-oriented programming has been at the center of mainstream software development since the early 1990s. Although OOP languages have evolved, the OO model foundation hasn't changed much. OOP is still deeply rooted in sequential programming within a single address space in the following ways:
Currently, several forces are pushing OOP and its foundations to overcome their limitations and be ready for highly concurrent and distributed systems. These forces include evolving hardware (e.g., multicore processors), increasing complexity of programming languages, and increasing level of expectation of new and growable software [Grogono 2008].
Despite the limitation, the OO model has proven to be a unifying concept in computer science [Booch 2007]. For this reason, I decided to leave the OO model untouched for computations (at which it is good) and add a component-based coordination model called the "Actor Virtual Machine" (AVM) as a new extension. A coordination model is the glue that binds separate computations into an ensemble [Gelernter 1992].
The AVM model brings to the OO model message-passing concurrency, which is the basic framework for multi-agent systems, the natural style for a distributed systems, and lends itself well to building reliable systems [Van Roy 2004]. Moreover, AVM customizes the message passing with a dynamic message-binding mechanism that encourages human interventions (e.g., hot code swapping, adjustable workflow) via visual syntax and tools at run time.
The AVM Model
The core idea behind the AVM model is to introduce an object, called the "AVM object", that forwards messages for objects. Sender objects synchronously invoke methods on the AVM object. The AVM object also synchronously invokes methods on receiver objects, but using its own threads. As a result, sender objects' thread of control never step into the inside of receiver objects. Thus asynchronous message passing is achieved between senders and receivers.
Sender and receiver objects are called actors for the sole reason that they are aware of an AVM object and use it for sending and/or receiving messages. Objects that work with an AVM object other than sending and/or receiving messages are not called actors. The name of actor is borrowed from the Actor Model, but AVM actors do not comply with the Actor Model. For example, AVM actors may carry out computations without receiving an incoming message, are not required to support become command for change of behaviors, etc. [Agha 1986].
The AVM model employs several techniques and elements, from basic to advanced. Code fragments use Java-like syntax for demonstration only. These techniques and elements are designed to be used individually as a utility toolbox or combined as a coordination language, which is based on message-passing concurrency, up to user's choices, where applicable.
Asynchronous Message Passing
Actors interact with each other by asynchronous message passing, which effectively breaks the abstraction that OO programs may be viewed as multiple sequential-thread routes over collections of objects, as asynchronous interaction separates the thread of control among actors.
The AVM model introduces an AVM object between a sender and a receiver. First, the sender invokes the AVMObject.send() method, and AVMObject immediately lets the sender's thread return. Then the AVMObject uses its own thread to invoke the receiver. onMessage() method. As a result, the sender successfully sends an asynchronous message to the receiver.
The AVM model requires that messages between a certain pair of sender and receiver arrive at the receiver's callback method in the order they are received by the AVMObject. A sender is required to know the references of the AVMObject and a receiver. The receiver is required to implement the AVMCallback.onMessage().
|
|
||||||||||||||||||||||||||||||
|
|
|
|