| 340 | |
| 341 | template <typename T> |
| 342 | void Task<T>::lowLevelTaskFunction(void* parameters) |
| 343 | { |
| 344 | Task* task = static_cast<Task*>(parameters); |
| 345 | |
| 346 | if ((nullptr != task) && |
| 347 | (nullptr != task->m_exitSemaphore)) |
| 348 | { |
| 349 | /* Grab the semaphore which is used later to signal that the |
| 350 | * task exited. |
| 351 | */ |
| 352 | (void)xSemaphoreTake(task->m_exitSemaphore, portMAX_DELAY); |
| 353 | |
| 354 | /* If a task function is available, it will be called instead of |
| 355 | * the default process method. |
| 356 | */ |
| 357 | if (nullptr != task->m_function) |
| 358 | { |
| 359 | while (false == task->m_reqExit) |
| 360 | { |
| 361 | task->m_function(task->m_parameters); |
| 362 | } |
| 363 | } |
| 364 | else |
| 365 | { |
| 366 | while (false == task->m_reqExit) |
| 367 | { |
| 368 | /* Call the default process method. */ |
| 369 | task->process(task->m_parameters); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | /* Signal that the task has exited. */ |
| 374 | (void)xSemaphoreGive(task->m_exitSemaphore); |
| 375 | } |
| 376 | |
| 377 | /* Delete the task itself. */ |
| 378 | vTaskDelete(nullptr); |
| 379 | } |
| 380 | |
| 381 | /****************************************************************************** |
| 382 | * Functions |