I have a project with quite a lot of multitasking inside, with each task might call for specific function, or 2 tasks call for 1 function with different parameter(s), either manually called or automatically scheduled.
From what I have experienced, return value applies globally, meaning that whichever condition at the same tick request a return value, all will read the same value returned.
On my project, I have a "synchronize" group that call for a sync function at every set duration. The sync will send an AJAX request to a remote server so the syncing process took several ticks to complete (~10 ticks). At the same time, I have a "user interface" group that will call for a function whenever a user calls them (~5 ticks).
Short illustration of the sync group:
every 300 tick {
value = get_sync();
[some actions...]
end
}
get_sync() {
var x;
[some actions...]
set return value to x;
}
[/code:30024806]
Short illustration of the UI group:
[code:30024806]if ( button_a pressed ) {
pin = get_auth(user_a);
[some actions...]
end
}
get_auth(var user) {
var y;
[some actions...]
set return value to y;
}
[/code:30024806]
The problem will occur if:
[code:30024806]
@ 1670 tick: get_sync (supposed to end at 1680)
@ 1675: get_auth()
@ 1680: value = pin = [returned value from one of the function above]
[/code:30024806]
Is there a way to differentiate a return value, to identify which function calls for it? Maybe like Function.ReturnValue("my_function")?