📚 The CoCalc Library - books, templates and other resources
cocalc-examples / martinthoma-latex-examples / documents / Programmierparadigmen / scripts / x10 / atomic-example.x10
201848 viewsLicense: OTHER
// push data on concurrent
// list-stack
val node = new Node(data);
atomic {
node.next = head;
head = node;
}
// target defined in
// enclosing scope
atomic def CAS(old:Object, n:Object) {
if (target.equals(old)) {
target = n;
return true;
}
return false;
}