From 5cb4f3a2af98c3f00cb63d419e855c2faaf9dae5 Mon Sep 17 00:00:00 2001 From: dario Date: Fri, 19 Jan 2024 12:42:05 +0100 Subject: [PATCH] Added customizable stack sizes for TacosThreads --- include/sta/tacos/thread.hpp | 13 ++++++++++--- src/thread.cpp | 11 ++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/sta/tacos/thread.hpp b/include/sta/tacos/thread.hpp index ca01469..660dd64 100644 --- a/include/sta/tacos/thread.hpp +++ b/include/sta/tacos/thread.hpp @@ -31,11 +31,18 @@ namespace sta { public: /** - * @brief Create a new thread with the given name and priority. + * @brief */ - TacosThread(const char* name, osPriority_t prio); - TacosThread(); + /** + * @brief Create a new thread with the given name and priority. + * + * @param name The thread's name. This is used for debugging. + * @param prio The thread's priority. Generally, this should be lower than the manager and statemachine priority. + * @param stack_size The stack size for the task. The default is the stack size specified in the FreeRTOS settings. + * @param cb_size The control block size for the task. The default is the size specified in the FreeRTOS settings. + */ + TacosThread(const char* name, osPriority_t prio, uint32_t stack_size = NULL, uint32_t cb_size = NULL); virtual ~TacosThread(); diff --git a/src/thread.cpp b/src/thread.cpp index 49c6b14..37b6073 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -19,17 +19,10 @@ namespace sta { namespace tacos { - TacosThread::TacosThread(const char* name, osPriority_t prio) + TacosThread::TacosThread(const char* name, osPriority_t prio, uint32_t stack_size = NULL, uint32_t cb_size = NULL) : RtosThread(RtosHandle(Handle::Deferred(&instance_))), instance_{ NULL }, - attribs_{ .name = name, .priority = prio }, - running_{false} - {} - - TacosThread::TacosThread() - : RtosThread(RtosHandle(Handle::Deferred(&instance_))), - instance_{ NULL }, - attribs_{ }, + attribs_{ .name = name, .priority = prio, .stack_size=stack_size, .cb_size=cb_size }, running_{false} {}