From b07cf9bb22af068a0c64120de714cfd518579149 Mon Sep 17 00:00:00 2001 From: CarlWachter Date: Tue, 22 Apr 2025 16:59:37 +0200 Subject: [PATCH] fix --- src/statemachine.cpp | 62 -------------------------------------------- 1 file changed, 62 deletions(-) diff --git a/src/statemachine.cpp b/src/statemachine.cpp index 8aa2d4e..819be45 100644 --- a/src/statemachine.cpp +++ b/src/statemachine.cpp @@ -24,8 +24,6 @@ namespace sta failsafeTimer_{[](void *){}, nullptr}, queue_{STA_TACOS_STATEMACHINE_QUEUE_LENGTH}, threads_{} - queue_{STA_TACOS_STATEMACHINE_QUEUE_LENGTH}, - threads_{} { STA_ASSERT(STA_TACOS_INITIAL_STATE < STA_TACOS_NUM_STATES); } @@ -221,66 +219,6 @@ namespace sta startThreads(state); } - void Statemachine::registerThread(std::shared_ptr thread, std::set states) - { - for (uint16_t state : states) - { - STA_ASSERT(state < STA_TACOS_NUM_STATES); - - threads_[state].push_back(thread); - } - } - - std::vector> Statemachine::getActiveThreads() - { - return threads_[tacos::getState()]; - } - - void Statemachine::startThreads(uint16_t state) - { - STA_ASSERT(state < STA_TACOS_NUM_STATES); - - for (std::shared_ptr thread : threads_[state]) - { - if (!thread->isRunning()) - { - thread->start(); - } - } - } - - void Statemachine::stopThreads(uint16_t state) - { - std::set> terminated; - - for (uint16_t other = 0; other < STA_TACOS_NUM_STATES; ++other) - { - if (other == state) - { - continue; - } - - for (std::shared_ptr thread : threads_[other]) - { - // If the thread is currently running but not part of the set of threads that should be running... - if (thread->isRunning() && terminated.count(thread) == 0 && std::count(threads_[state].begin(), threads_[state].end(), thread) == 0) - { - // ...politely request termination. - thread->requestTermination(); - terminated.emplace(thread); - } - } - } - } - - void Statemachine::updateThreads() - { - uint16_t state = getCurrentState(); - - stopThreads(state); - startThreads(state); - } - Statemachine* Statemachine::_instance = nullptr; RtosEvent Statemachine::stateChangeEvent;