Linguistic Symbiosis between Actors and Threads
Tom Van Cutsem Stijn Mostinckx Wolfgang De Meuter
Programming Technology Lab Vrije Universiteit Brussel Brussels, Belgium
International Conference on Dynamic Languages, August 27th 2007, Lugano
Linguistic Symbiosis between Actors and Threads Tom Van Cutsem - - PowerPoint PPT Presentation
Linguistic Symbiosis between Actors and Threads Tom Van Cutsem Stijn Mostinckx Wolfgang De Meuter Programming Technology Lab Vrije Universiteit Brussel Brussels, Belgium International Conference on Dynamic Languages, August 27th 2007,
Tom Van Cutsem Stijn Mostinckx Wolfgang De Meuter
Programming Technology Lab Vrije Universiteit Brussel Brussels, Belgium
International Conference on Dynamic Languages, August 27th 2007, Lugano
2
3
actor: { def obj := object: { def m() { ... } } def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) {
} })
}
3
actor: { def obj := object: { def m() { ... } } def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) {
} })
}
4
Event Event Queue Event Loop Event Handler
5
Actor
Message queue
Event loop
Based on E programming language [Miller05]
5
Actor
Message queue
Event loop
‘local’ object
Based on E programming language [Miller05]
5
Actor
Message queue
Event loop
‘local’ object
Based on E programming language [Miller05]
5
Actor
Message queue
Event loop
‘local’ object ‘remote’ object
Based on E programming language [Miller05]
5
Actor
Message queue
Event loop
‘local’ object ‘remote’ object
Based on E programming language [Miller05]
5
Actor
Message queue
Event loop
‘local’ object ‘remote’ object
Actors cannot cause deadlock No race conditions on objects
Based on E programming language [Miller05]
6
Based on Inter-language Reflection [Gybels et al 05]
def Button := jlobby.java.awt.Button; def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } }); button.setVisible(true);
7
7
8
Actor
def obj := object: { ... }; aJavaCollection.add(obj);
aJavaCollection
8
Actor
def obj := object: { ... }; aJavaCollection.add(obj);
aJavaCollection add(obj)
8
Actor
def obj := object: { ... }; aJavaCollection.add(obj);
aJavaCollection add(obj)
8
Actor
def obj := object: { ... }; aJavaCollection.add(obj);
synchronizedCol add(obj)
9
Actor
def obj := object: { def compareTo(other) { ... } } aJavaCollection.add(obj);
aJavaCollection
9
Actor
def obj := object: { def compareTo(other) { ... } } aJavaCollection.add(obj);
aJavaCollection add(obj)
9
Actor
def obj := object: { def compareTo(other) { ... } } aJavaCollection.add(obj);
aJavaCollection add(obj)
9
Actor
def obj := object: { def compareTo(other) { ... } } aJavaCollection.add(obj);
aJavaCollection add(obj) compareTo(obj2)
9
Actor
def obj := object: { def compareTo(other) { ... } } aJavaCollection.add(obj);
aJavaCollection add(obj)
10
def ambientTalkTest := object: { def countTestCases() { ... } def run(result) { ... } } interface junit.framework.Test { public int countTestCases(); public void run(TestResult r); }
10
def ambientTalkTest := object: { def countTestCases() { ... } def run(result) { ... } } TestSuite suite = new TestSuite(); ATObject atUnitTest = /* load ambienttalk test */; suite.addTest((Test) wrap(atUnitTest, Test.class)); suite.addTest(aJavaUnitTest); junit.textuit.TestRunner.run(suite); interface junit.framework.Test { public int countTestCases(); public void run(TestResult r); }
Actor
ambientTalkTest suite
10
Actor
ambientTalkTest suite
10
run(result)
Actor
ambientTalkTest suite
10
run(result)
Actor
ambientTalkTest suite
10
Actor
ambientTalkTest suite
10
wrapper
Actor
ambientTalkTest suite
10
wrapper barrier.get()
Actor
ambientTalkTest suite
10
wrapper barrier.get()
Actor
ambientTalkTest suite
10
wrapper barrier.get()
11
ActionListener l = ...; l.actionPerformed(actionEvent);
def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } });
Actor
buttonListener button
11
ActionListener l = ...; l.actionPerformed(actionEvent);
def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } });
Actor
buttonListener button
11
actionPerformed(ae)
ActionListener l = ...; l.actionPerformed(actionEvent);
def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } });
Actor
buttonListener button
11
ActionListener l = ...; l.actionPerformed(actionEvent);
wrapper def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } });
Actor
buttonListener button
11
ActionListener l = ...; l.actionPerformed(actionEvent);
wrapper def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } });
Actor
buttonListener button
11
ActionListener l = ...; l.actionPerformed(actionEvent);
wrapper def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } });
Actor
buttonListener button
11
ActionListener l = ...; l.actionPerformed(actionEvent);
wrapper def button := Button.new(“Click Me”); button.addActionListener(object: { def actionPerformed(actionEvent) { ... } });
Actor
buttonListener button
11
wrapper interface I extends java.util.EventListener { public void event(...); }
12
12
collection.add(obj)
12
12
12
unitTest.run(reporter)
12
listener.actionPerformed(ae)
13
14
http://prog.vub.ac.be/amop