-
Notifications
You must be signed in to change notification settings - Fork 32
Compiler implementation gotchas
Jakob Høgenes edited this page Apr 20, 2018
·
1 revision
When an event occurs in an instance that has forked sessions, ThingML specifies that this event should be cloned to all those sessions, and then handled (possibly in parallel). One must make sure that if a new session is forked as part of handling this event, the new session does not get a copy of the causing event. E.g., the following pseudo-implementation of a Thing, would lead to erroneous and unpredictable behaviour:
class SomeThing {
list<SomeThing> forks;
func receive(event) {
this.handle(event.clone());
for (child : forks) {
child.handle(event.clone());
}
}
func handleSomeSpecificEvent() {
// Fork a new session
this.forks.append(new SomeThing());
}
}
Visit thingml.org to find out more about ThingML !