Skip to content

Commit ad42664

Browse files
concept/rules: state that a rule cannot be executed in parallel
1 parent b199256 commit ad42664

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

concepts/rules.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ openHAB can send a notification to your phone.
2121
Other systems may have a concept of _Automations_, _Tasks_, and other terms.
2222
In openHAB, rules are used to implement all of these concepts.
2323

24+
Rules can be executed, either when fired by their triggers, or when called explicitly - from a script, another rule, MainUI widget.
25+
When a rule is fired by its trigger, the execution of one and the same rule does not happen in parallel.
26+
If a rule is triggered for execution, while the rule is currently running, it will be queued and run later.
27+
28+
When a rule is called explicitly - from a script, another rule with [`RuleManager.runNow()`](https://www.openhab.org/javadoc/latest/org/openhab/core/automation/rulemanager), from a MainUI widget, then this rule can be executed in parallel.
29+
That is it can start running, while the same rule is executed at the same time.
30+
In this case there is a need to program protection against race conditions.
31+
2432
## Parts of a Rule
2533

2634
These rules take the high level form of _When \_\_t\_\_ happens, if \_\_c\_\_ then do \_\_a\_\__,

configuration/rules-dsl.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,8 @@ Caveat: Please note the semicolon after the return statement which terminates th
801801

802802
### Concurrency Guard
803803

804-
If a rule triggers on UI events it may be necessary to guard against concurrency.
804+
If a rule is explicitly run from another script, rule, MainUI widget, instead of a trigger, the rule can be started before the current execution has ended
805+
It may be necessary to guard against concurrency.
805806

806807
```javascript
807808
import java.util.concurrent.locks.ReentrantLock

0 commit comments

Comments
 (0)