Copyright Tristan Aubrey-Jones May 2008.
Abstract: A project investigating and developing an implicitly concurrent programming language, based on a metaphor taken from the physical world is reported. Uses a programming paradigm where programs consist of systems of autonomous agents, or active objects which communicate via message passing. A language enhancing Java with actors and linear types is presented. Example programs are written, compiled, and executed to evaluate the usefulness of the language. The language found to provide a familiar notation for implicit parallelism, and a compelling new model for concurrency, combining the performance of shared variables with the elegance of message passing.
Introductory Slides (PDF),
Report (PDF),
ActiveJava compiler prototype (ajavac),
ActiveJava runtime library (ajava_lang).
Examples:
calc - pocket calculator actor program dining - dining philosophers actor program (never deadlocks) sort - parallel quicksort implementation ("SortBenchmark" sorts 10,000 random integers using actors, java threads, and sequentially and compares)To compile examples use:
compile.bat ./calc compile.bat ./sort compile.bat ./diningTo run examples use:
run ./calc Main run ./dining Main run ./dining Main fast run ./sort Main run ./sort SortingBenchmark
import org.taj.ajava.lang.*;
public class Stdout extends Actor
{
private void react_0(String v)
{
System.out.print(v);
}
public void deliver(String v)
{
bufferMessage(new org.taj.ajava.runtime.ActorMessage(v, 0));
}
protected void react(String v)
{
react_0(v);
}
private void react_1(int v)
{
System.out.print(v);
}
public void deliver(int v)
{
bufferMessage(new org.taj.ajava.runtime.ActorMessage(new Integer(v), 1));
}
protected void react(int v)
{
react_1(v);
}
private void react_2(Object o)
{
this.react(o.toString());
}
public void deliver(Object o)
{
bufferMessage(new org.taj.ajava.runtime.ActorMessage(o, 2));
}
protected void react(Object o)
{
react_2(o);
}
protected void processMessage(org.taj.ajava.runtime.ActorMessage msg)
{
switch (msg.reactorId) {
case 0:
{
react_0(((String)msg.payload));
return;
}
case 1:
{
react_1(((Integer)msg.payload).intValue());
return;
}
case 2:
{
react_2(((Object)msg.payload));
return;
}
default:
{
super.processMessage(msg);
return;
}
}
}
private Stdout()
{
}
private static class SingletonHolder
{
private final static Stdout instance = new Stdout();
}
public static Stdout getInstance()
{
return SingletonHolder.instance;
}
}