4#include "freertos/FreeRTOS.h"
5#include "freertos/task.h"
6#elif defined(__linux__)
13#include "AudioLogger.h"
44 Task(
const char* name,
int stackSizeWords,
int priority = 1,
int core = -1)
56 bool create(
const char* name,
int stackSizeWords,
int priority = 1,
62 if (priority >= configMAX_PRIORITIES) {
63 priority = configMAX_PRIORITIES - 1;
64 LOGW(
"clamped task priority to %d ", priority);
69 rc = xTaskCreatePinnedToCore(
task_loop, name, stackSizeWords,
this,
72 rc = xTaskCreate(
task_loop, name, stackSizeWords,
this, priority,
75 if (rc != pdPASS ||
xHandle ==
nullptr) {
76 LOGE(
"could not create task %s", name);
82 rc = xTaskCreate(
task_loop, name, stackSizeWords,
this, priority,
84 if (rc != pdPASS ||
xHandle ==
nullptr) {
85 LOGE(
"could not create task %s", name);
90#if defined(configUSE_CORE_AFFINITY) && (configUSE_CORE_AFFINITY == 1) && \
91 (configNUMBER_OF_CORES > 1)
94 if (core >= 0) vTaskCoreAffinitySet(
xHandle, (1 << core));
110 bool begin(std::function<
void()> process) {
111 LOGI(
"starting task");
117 LOGE(
"task not created: call create() or use the named constructor");
131 if (
xHandle ==
nullptr)
return;
137 if (
xHandle ==
nullptr)
return;
165 return xPortGetCoreID();
int BaseType_t
Definition BufferBlocking.h:12