Skip to content

Instantly share code, notes, and snippets.

@kris7t
Created December 27, 2017 22:43
Show Gist options
  • Save kris7t/d9c28ca22109d89851e37211ce3ff839 to your computer and use it in GitHub Desktop.
Save kris7t/d9c28ca22109d89851e37211ce3ff839 to your computer and use it in GitHub Desktop.
mission DinnerParty(Table) with DiningPhilosophers {
initial phase start
phase arrived
phase waitForFinish
phase left
final phase finish
var Phil
start -> arrived [adjacentPhilosophers(Table, Left, Right)] after 10 weight (Left.eatingRate + Right.eatingRate) /
let Phil = philosophers.PhilosophersFactory.eINSTNACE.createPhilosopher => [
name = "Soren Kierkegaard"
hungryRate = 0.12
eatingRate = 2.5
left = Left
right = Right
],
do {
Table.philosophers += Phil
}
arrived -> waitForFinish after 25
waitForFinish -> left [lookup philosopher(Table, Phil) as PhilM] on first (#PhilM.leftFork == 0 && #PhilM.rightFork == 0) /
do {
Phil.left.right = Phil.right
Table.philosophers -= Phil
}
left -> finish after 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment