This object is in archive! 
Rule execution semantics
Need Answer
Can more and one rule execute at the same time?
If not; what about long running rules, will they temporarily halt the rule engine?
If they can, are variables safe to use across rules (~thread safe in programs)?
No connection
Real-time notifications may not work
David,
Rules seem to execute simultaneously. If you have a very long WAIT in one rule, it will not stop other rules from being executed.
Variables seem to be global, i.e. contents can be set in one rule and read or manipulated in another.
Brgds
Robert
David,
Rules seem to execute simultaneously. If you have a very long WAIT in one rule, it will not stop other rules from being executed.
Variables seem to be global, i.e. contents can be set in one rule and read or manipulated in another.
Brgds
Robert
David,
I have just tested, and can confirm that variables are NOT thread safe (or Rule safe).
A variable accessed at one point inside a rule, can be changed by another rule, before the rule has completed its execution.
The enclosed two rules will demonstrate this quite well: Each of the rules have a Scheduler. The first rule is set to execute every minute, the second will execute every five minutes. The SEND actions simply send messages. If you have PRO, the messages can also include the contents of the variables.
The FiveMinuteRule store the value of a variable which is incremented every minute in the OneMinuteRule, into another variable, then the rule waits for 4 minute, then compare the contents of the variable with the variable holding its initial contents.
The variable will have been changed every minute by the OneMinuteRule, and will be different when tested the second time inside the rule.
David,
I have just tested, and can confirm that variables are NOT thread safe (or Rule safe).
A variable accessed at one point inside a rule, can be changed by another rule, before the rule has completed its execution.
The enclosed two rules will demonstrate this quite well: Each of the rules have a Scheduler. The first rule is set to execute every minute, the second will execute every five minutes. The SEND actions simply send messages. If you have PRO, the messages can also include the contents of the variables.
The FiveMinuteRule store the value of a variable which is incremented every minute in the OneMinuteRule, into another variable, then the rule waits for 4 minute, then compare the contents of the variable with the variable holding its initial contents.
The variable will have been changed every minute by the OneMinuteRule, and will be different when tested the second time inside the rule.
I think rules cannot simultaneously run, this is not a multicore processor that can run different tasks (with different core) at the same time. In my opinion the processor runs one rule after another as fast as it can, WAIT and REPEAT puzzles don't "trap" processor execution, in my opinion they continue processing other rules until the Timer or the Counter is done. I created a rule to show the secuencial process of the rules, I guess the rules run based on the number of rule, i. e. Rule 1, Rule 2, Rule 3, etc.
First image shows the rules I created as a "timestamp" demonstration of when the rule runs. On the second image you can see VAR1 has a smaller value than VAR2, since I created and saved VAR1 rule first and then second. Then I moved VAR2 rule on top of VAR1 rule, syncronized rules, and then run again and now VAR2 has a smaller value than VAR1, third image.
I think rules cannot simultaneously run, this is not a multicore processor that can run different tasks (with different core) at the same time. In my opinion the processor runs one rule after another as fast as it can, WAIT and REPEAT puzzles don't "trap" processor execution, in my opinion they continue processing other rules until the Timer or the Counter is done. I created a rule to show the secuencial process of the rules, I guess the rules run based on the number of rule, i. e. Rule 1, Rule 2, Rule 3, etc.
First image shows the rules I created as a "timestamp" demonstration of when the rule runs. On the second image you can see VAR1 has a smaller value than VAR2, since I created and saved VAR1 rule first and then second. Then I moved VAR2 rule on top of VAR1 rule, syncronized rules, and then run again and now VAR2 has a smaller value than VAR1, third image.
Although not on true parallel, things can be executed in semi-parallel in single core processors by using threads. This is probably what happens here. Each rule executed in their own thread and appears to run in parallel.
Although not on true parallel, things can be executed in semi-parallel in single core processors by using threads. This is probably what happens here. Each rule executed in their own thread and appears to run in parallel.
Replies have been locked on this page!