mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-06 17:47:34 +00:00
Added reworked manager / statemachine tasks, thread implementation and new directory layout
This commit is contained in:
86
Tacos/include/sta/tacos/manager.hpp
Normal file
86
Tacos/include/sta/tacos/manager.hpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* manager.hpp
|
||||
*
|
||||
* Created on: Sep 19, 2023
|
||||
* Author: Dario
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_STA_TACOS_MANAGER_HPP_
|
||||
#define INCLUDE_STA_TACOS_MANAGER_HPP_
|
||||
|
||||
|
||||
#include <sta/config.hpp>
|
||||
|
||||
#ifndef STA_TACOS_MANAGER_PRIORITY
|
||||
# error "Manger task priority not specified in config.hpp"
|
||||
#else
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <sta/tacos/thread.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
{
|
||||
class Manager : public TacosThread
|
||||
{
|
||||
public:
|
||||
static Manager* instance()
|
||||
{
|
||||
static CGuard g;
|
||||
|
||||
if (!_instance)
|
||||
{
|
||||
// Create a the manager singleton instance.
|
||||
Manager::_instance = new Manager();
|
||||
|
||||
// Start the manager task as a tacos task.
|
||||
Manager::_instance->start();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void registerThread(TacosThread thread, std::list<uint16_t> states);
|
||||
|
||||
void init() override;
|
||||
|
||||
void func() override;
|
||||
|
||||
private:
|
||||
class CGuard
|
||||
{
|
||||
public:
|
||||
~CGuard()
|
||||
{
|
||||
if( NULL != Manager::_instance )
|
||||
{
|
||||
delete Manager::_instance;
|
||||
Manager::_instance = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static Manager* _instance;
|
||||
|
||||
Manager();
|
||||
|
||||
Manager(const Manager&);
|
||||
|
||||
~Manager() {}
|
||||
|
||||
void updateThreads();
|
||||
|
||||
void startThreads(uint16_t state);
|
||||
|
||||
void stopThreads(uint16_t state);
|
||||
|
||||
std::set<TacosThread> threads_[STA_TACOS_NUM_STATES];
|
||||
};
|
||||
} // namespace tacos
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_TACOS_MANAGER_PRIORITY
|
||||
|
||||
#endif /* INCLUDE_STA_TACOS_MANAGER_HPP_ */
|
Reference in New Issue
Block a user