From 12d6303f2e39892b682257e0dfc2848978f3aae2 Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 3 Jan 2024 15:17:38 +0100 Subject: [PATCH] Added working blocking-wrapper --- include/sta/tacos/configs/default.hpp | 2 +- include/sta/tacos/thread.hpp | 9 ++++++++- src/thread.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/sta/tacos/configs/default.hpp b/include/sta/tacos/configs/default.hpp index 8f479c3..119c247 100644 --- a/include/sta/tacos/configs/default.hpp +++ b/include/sta/tacos/configs/default.hpp @@ -12,4 +12,4 @@ // Per default, we assume state 0 to be the initial state. #define STA_TACOS_INITIAL_STATE 0 -#endif // STA_TACOS_CONFIGS_DEFAULT_HPP \ No newline at end of file +#endif // STA_TACOS_CONFIGS_DEFAULT_HPP diff --git a/include/sta/tacos/thread.hpp b/include/sta/tacos/thread.hpp index 243d377..d8f3b29 100644 --- a/include/sta/tacos/thread.hpp +++ b/include/sta/tacos/thread.hpp @@ -127,7 +127,14 @@ namespace sta virtual void cleanup(); #ifdef STA_TACOS_WATCHDOG_ENABLED - #define BLOCKING(stmt) waiting(); stmt heartbeat() + /** + * @brief This macro wraps a given statement into waiting() and heartbeat() to make the code more readable. + * + */ + #define blocking(...) \ + waiting(); \ + __VA_ARGS__ \ + heartbeat(); \ protected: /** diff --git a/src/thread.cpp b/src/thread.cpp index e3a1640..662ba62 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -23,9 +23,9 @@ namespace sta : RtosThread(RtosHandle(Handle::Deferred(&instance_))), instance_{ NULL }, attribs_{ .name = name, .priority = prio }, - running_{false}, + running_{false} #ifdef STA_TACOS_WATCHDOG_ENABLED - status_{ThreadStatus::STOPPED} + , status_{ThreadStatus::STOPPED} #endif // STA_TACOS_WATCHDOG_ENABLED {} @@ -33,9 +33,9 @@ namespace sta : RtosThread(RtosHandle(Handle::Deferred(&instance_))), instance_{ NULL }, attribs_{ }, - running_{false}, + running_{false} #ifdef STA_TACOS_WATCHDOG_ENABLED - status_{ThreadStatus::STOPPED} + , status_{ThreadStatus::STOPPED} #endif // STA_TACOS_WATCHDOG_ENABLED {}