From aace84a8addc25d7f481178d318efe533ba46698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B8=D0=BB=D1=8F=D0=BD=20=D0=9F=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=D1=83=D0=B7=D0=BE=D0=B2?= Date: Sat, 4 Oct 2025 16:58:35 +0300 Subject: [PATCH 1/5] concept/rules: state that a rule cannot be executed in parallel --- concepts/rules.md | 8 ++++++++ configuration/rules-dsl.md | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/concepts/rules.md b/concepts/rules.md index cec390f268..29433cfc2e 100644 --- a/concepts/rules.md +++ b/concepts/rules.md @@ -21,6 +21,14 @@ openHAB can send a notification to your phone. Other systems may have a concept of _Automations_, _Tasks_, and other terms. In openHAB, rules are used to implement all of these concepts. +Rules can be executed, either when fired by their triggers, or when called explicitly - from a script, another rule, MainUI widget. +When a rule is fired by its trigger, the execution of one and the same rule does not happen in parallel. +If a rule is triggered for execution, while the rule is currently running, it will be queued and run later. + +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. +That is it can start running, while the same rule is executed at the same time. +In this case there is a need to program protection against race conditions. + ## Parts of a Rule These rules take the high level form of _When \_\_t\_\_ happens, if \_\_c\_\_ then do \_\_a\_\__, diff --git a/configuration/rules-dsl.md b/configuration/rules-dsl.md index 1e364b1e70..129282e9fd 100644 --- a/configuration/rules-dsl.md +++ b/configuration/rules-dsl.md @@ -801,7 +801,8 @@ Caveat: Please note the semicolon after the return statement which terminates th ### Concurrency Guard -If a rule triggers on UI events it may be necessary to guard against concurrency. +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. +It may be necessary to guard against concurrency. ```javascript import java.util.concurrent.locks.ReentrantLock From 44bfc102f49bacf7b7a75c977b25198be00d6850 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 17 Dec 2025 18:53:32 +0100 Subject: [PATCH 2/5] Apply suggestions from code review Signed-off-by: Florian Hotze --- concepts/rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts/rules.md b/concepts/rules.md index 29433cfc2e..5c14c956c8 100644 --- a/concepts/rules.md +++ b/concepts/rules.md @@ -21,7 +21,7 @@ openHAB can send a notification to your phone. Other systems may have a concept of _Automations_, _Tasks_, and other terms. In openHAB, rules are used to implement all of these concepts. -Rules can be executed, either when fired by their triggers, or when called explicitly - from a script, another rule, MainUI widget. +Rules can be executed, either when fired by their triggers, or when called explicitly - from a script, another rule, or a Main UI widget. When a rule is fired by its trigger, the execution of one and the same rule does not happen in parallel. If a rule is triggered for execution, while the rule is currently running, it will be queued and run later. From 8b7fed6fa9db3859af8f280a6ba83428ab426b60 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 17 Dec 2025 18:54:05 +0100 Subject: [PATCH 3/5] Apply suggestions from code review Signed-off-by: Florian Hotze --- concepts/rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts/rules.md b/concepts/rules.md index 5c14c956c8..c2ffe9c32e 100644 --- a/concepts/rules.md +++ b/concepts/rules.md @@ -25,7 +25,7 @@ Rules can be executed, either when fired by their triggers, or when called expli When a rule is fired by its trigger, the execution of one and the same rule does not happen in parallel. If a rule is triggered for execution, while the rule is currently running, it will be queued and run later. -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. +When a rule is called explicitly - e.g. from a script, another rule with [`RuleManager.runNow()`](https://www.openhab.org/javadoc/latest/org/openhab/core/automation/rulemanager), or from a Main UI widget - then this rule can be executed in parallel. That is it can start running, while the same rule is executed at the same time. In this case there is a need to program protection against race conditions. From c6bdb22c68430e94fd5b2a5eecb3e60d722d9e12 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Fri, 19 Dec 2025 21:54:20 +0100 Subject: [PATCH 4/5] Review changes Signed-off-by: Florian Hotze --- concepts/rules.md | 2 +- configuration/rules-dsl.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/concepts/rules.md b/concepts/rules.md index c2ffe9c32e..da0d40c094 100644 --- a/concepts/rules.md +++ b/concepts/rules.md @@ -21,7 +21,7 @@ openHAB can send a notification to your phone. Other systems may have a concept of _Automations_, _Tasks_, and other terms. In openHAB, rules are used to implement all of these concepts. -Rules can be executed, either when fired by their triggers, or when called explicitly - from a script, another rule, or a Main UI widget. +Rules can be executed, either when fired by their triggers, or when called explicitly - from a script, another rule, a Main UI widget, etc. When a rule is fired by its trigger, the execution of one and the same rule does not happen in parallel. If a rule is triggered for execution, while the rule is currently running, it will be queued and run later. diff --git a/configuration/rules-dsl.md b/configuration/rules-dsl.md index 129282e9fd..9178de866f 100644 --- a/configuration/rules-dsl.md +++ b/configuration/rules-dsl.md @@ -801,7 +801,7 @@ Caveat: Please note the semicolon after the return statement which terminates th ### Concurrency Guard -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. +If a rule is explicitly run from another script, rule, a Main UI widget, etc., instead of a trigger, the rule can be started before the current execution has ended. It may be necessary to guard against concurrency. ```javascript From e546dd83ff94b3075f6f581941fb232170ac7bde Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Fri, 19 Dec 2025 21:54:49 +0100 Subject: [PATCH 5/5] Review changes Signed-off-by: Florian Hotze --- concepts/rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts/rules.md b/concepts/rules.md index da0d40c094..22ce9c9d46 100644 --- a/concepts/rules.md +++ b/concepts/rules.md @@ -21,7 +21,7 @@ openHAB can send a notification to your phone. Other systems may have a concept of _Automations_, _Tasks_, and other terms. In openHAB, rules are used to implement all of these concepts. -Rules can be executed, either when fired by their triggers, or when called explicitly - from a script, another rule, a Main UI widget, etc. +Rules can be executed, either when fired by their triggers, or when called explicitly – from a script, another rule, a Main UI widget, etc. When a rule is fired by its trigger, the execution of one and the same rule does not happen in parallel. If a rule is triggered for execution, while the rule is currently running, it will be queued and run later.