1)If I have a module level variable(array and other primitive types)
AFAIU we don't need to use a lock as we are using same thread.
string[] menu = ["pizza", "hot dog", "fries"];
public function main() {
while true {
if (//some breaking condition) {
break;
}
future<int> f = start modifyMenu(//some string);
}
}
function modifyMenu(string dish) {
// Do we need below lock??
lock {
menu.push(dish);
}
}
2)If I have a module level object and it is modified with a method(array and other primitive types)
Data data = new();
class Data {
string[] datasets = [];
function append(string string) {datasets.push(string);}
}
public function main() {
decimal now = time:monotonicNow();
while true {
if (//some breaking condition) {
break;
}
future<int> f = start modifyMenu(//some string);
}
}
function modifyMenu(string dish) {
// Do we need below lock??
lock {
data.append(dish);
}
}
Please explain isolation objects , isolation methods.. How to use them for above situation??