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 javax.swing.*;
public aclass NumberBox extends AComponent {
protected JTextField textField;
private boolean reset = false;
private boolean donePoint = false;
public final Event OnOperation = new Event();
public NumberBox() {
super(new JTextField(15));
textField = (JTextField)(component);
textField.setHorizontalAlignment(JTextField.RIGHT);
textField.setText("0");
}
// appends a character (digit, or point)
// to the current numeral
public react (char c) {
// digit
if (Character.isDigit(c)) {
if (reset) {
textField.setText("" + c);
reset = false;
}
else if (textField.getText().equals("0")) {
if (c != '0') textField.setText("" + c);
} else {
textField.setText(textField.getText() + "" + c);
}
}
// decimal point
else if (c == '.' && !donePoint) {
textField.setText(textField.getText() + '.');
donePoint = true;
}
}
// injects the current operand into the operation
// and forwards it to the ALU
public react (Calculator.Operation op) {
// pass to ALU
op.operand = Double.parseDouble(textField.getText());
OnOperation <-- op;
}
// sets the value, resulting from an ALU
// operation
public react (double v) {
textField.setText(Double.toString(v));
reset = true;
donePoint = false;
}
}