You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
behavior B_Coordinator {
var teamRoles = new HashMap<String, Integer>()
on Initialize {
teamRoles = occurrence.parameters.get(0) as HashMap<String, Integer>
...
I get the "The field teamRoles should be synchronized for avoiding value inconsistency due to parallel execution"
My understanding is that each B_Coordinator behaviour is different for each agent when attaching it to an agent, so they do not share the same teamRoles and there could be no problems due to || executions. And of course a behavior can only be initialized once right?
So shouldn't be the case that the Initialize of behaviors shold never rise these warnings as they are by definition executed once? Maybe I am not understanding soemthing
System configuration:
-- SARL version: 0.10.0
-- SARL compiler: 0.10.0
Eclipse compiler without Maven
Eclipse compiler with Maven
Maven compiler on the command line
sarlc compiler
-- Java JDK version (with the manufacturer name): OpenJDK 11
-- Operating System:
Linux 64bits
Windows 64bits
MacOS 64bits
The text was updated successfully, but these errors were encountered:
You could declare multiple times a on Initialize into a single behavior (as in an Agent). Please note that the documentation is not enough clear at this moment, and it should be updated to explain that multiple on Initialize could be declared.
All of the on Initialize are executed in parallel. In this case the parallel access to your field is possible.
I understand that from your code, we are almost sure that there is no possible parallel execution because there is only one on Initialize in the current behavior, and there is no super behavior that is extended (and that may implement its own on Initialize).
But, because your behavior is not declared as final (i.e., it is still overridable), on Initialize could be declared into a sub-type of your behavior. In this case, you may encounter parallel access issues.
Unfortunatelly, if you add the final modifier to your behavior, it will not remove the warning for now. Indeed, the SARL validator does not do a so detailled analysis of the code as the one above, until now. It may be a nice enhancement for the coming version.
Keep in your mind that the synchronization issues that are generated by the SARL compiler are warnings (should be considered, could be ignored). We plan to remove them in one of the coming versions (see Issue #208).
I keep this issue open in order to:
Update the documentation regarding the explanation on the multiple declaration of on Initialize.
Description of your issue:
Suppose this code:
I get the "The field teamRoles should be synchronized for avoiding value inconsistency due to parallel execution"
My understanding is that each
B_Coordinator
behaviour is different for each agent when attaching it to an agent, so they do not share the sameteamRoles
and there could be no problems due to || executions. And of course a behavior can only be initialized once right?So shouldn't be the case that the
Initialize
of behaviors shold never rise these warnings as they are by definition executed once? Maybe I am not understanding soemthingSystem configuration:
-- SARL version: 0.10.0
-- SARL compiler: 0.10.0
-- Java JDK version (with the manufacturer name): OpenJDK 11
-- Operating System:
The text was updated successfully, but these errors were encountered: