|
@@ -11,18 +11,17 @@
|
|
|
|
|
|
#include "kbf/exception.h"
|
|
|
|
|
|
-/**
|
|
|
- * @brief Task handling functions.
|
|
|
- */
|
|
|
-namespace kbf::task {
|
|
|
+namespace kbf {
|
|
|
/** @brief Tag used for logging. */
|
|
|
static constexpr const char *const TAG = "kbf::task";
|
|
|
|
|
|
class Task;
|
|
|
|
|
|
- template<class T>
|
|
|
- std::shared_ptr<Task>
|
|
|
- start(const std::string &name, void *arg, uint32_t stackSize = 2048, uint32_t priority = 5);
|
|
|
+ namespace task {
|
|
|
+ template<class T>
|
|
|
+ std::shared_ptr<Task>
|
|
|
+ start(const std::string &name, void *arg, uint32_t stackSize = 2048, uint32_t priority = 5);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* @brief Base class for tasks.
|
|
@@ -31,8 +30,8 @@ namespace kbf::task {
|
|
|
class Task {
|
|
|
template<class T>
|
|
|
friend std::shared_ptr<Task>
|
|
|
- start(const std::string &name, void *arg, // NOLINT(readability-redundant-declaration
|
|
|
- uint32_t stackSize, uint32_t priority);
|
|
|
+ kbf::task::start(const std::string &name, void *arg, // NOLINT(readability-redundant-declaration
|
|
|
+ uint32_t stackSize, uint32_t priority);
|
|
|
|
|
|
public:
|
|
|
/** @brief Name of the RTOS task. */
|
|
@@ -45,7 +44,7 @@ namespace kbf::task {
|
|
|
[[maybe_unused]] const uint32_t priority;
|
|
|
|
|
|
/** @brief Tag used for logging. */
|
|
|
- static constexpr const char *const TAG = "kbf::task::Task";
|
|
|
+ static constexpr const char *const TAG = "kbf::Task";
|
|
|
|
|
|
Task() = delete;
|
|
|
|
|
@@ -93,10 +92,11 @@ namespace kbf::task {
|
|
|
bool running_ = false;
|
|
|
|
|
|
class TaskList {
|
|
|
- static constexpr const char *const TAG = "kbf::task::TaskList";
|
|
|
+ static constexpr const char *const TAG = "kbf::Task::TaskList";
|
|
|
+
|
|
|
template<class T>
|
|
|
friend std::shared_ptr<Task>
|
|
|
- start(const std::string &name, void *arg, // NOLINT(readability-redundant-declaration
|
|
|
+ task::start(const std::string &name, void *arg, // NOLINT(readability-redundant-declaration
|
|
|
uint32_t stackSize, uint32_t priority);
|
|
|
|
|
|
friend class Task;
|
|
@@ -108,10 +108,15 @@ namespace kbf::task {
|
|
|
static void remove(uint32_t id);
|
|
|
};
|
|
|
};
|
|
|
+}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Task handling.
|
|
|
+ */
|
|
|
+namespace kbf::task {
|
|
|
/**
|
|
|
* @brief Starts a task.
|
|
|
- * @tparam T must be subclass of kbf::task::Task
|
|
|
+ * @tparam T must be subclass of kbf::Task
|
|
|
* @param name RTOS task name
|
|
|
* @param arg arguments passed to run()
|
|
|
* @param stackSize stack size
|
|
@@ -121,7 +126,7 @@ namespace kbf::task {
|
|
|
template<class T>
|
|
|
std::shared_ptr<Task>
|
|
|
start(const std::string &name, void *arg, const uint32_t stackSize, const uint32_t priority) {
|
|
|
- static_assert(std::is_base_of<Task, T>::value, "kbf::task::run(): type must be a kbf::task::Task");
|
|
|
+ static_assert(std::is_base_of<Task, T>::value, "kbf::task::start(): type must be a kbf::task::Task");
|
|
|
auto task = std::make_shared<T>(name, arg, stackSize, priority);
|
|
|
|
|
|
esp_err_t err = xTaskCreate(Task::runInternal, name.c_str(), stackSize, task.get(), priority, &task->handle);
|