diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-05-02 17:06:25 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-05-02 17:06:25 +1000 |
| commit | a231fd1c8afedbeb14b0bc77d76bad61db986059 (patch) | |
| tree | 5cbb12f502445776072b691bdebcd0ef6ef54d12 /src/tasks | |
| parent | f852e447159757a92564327c6b114f929200b3a0 (diff) | |
| download | tangara-fw-a231fd1c8afedbeb14b0bc77d76bad61db986059.tar.gz | |
Replace cpp::span shim with std::span
Diffstat (limited to 'src/tasks')
| -rw-r--r-- | src/tasks/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/tasks/tasks.cpp | 10 | ||||
| -rw-r--r-- | src/tasks/tasks.hpp | 8 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/tasks/CMakeLists.txt b/src/tasks/CMakeLists.txt index 0fdacf78..814c9943 100644 --- a/src/tasks/CMakeLists.txt +++ b/src/tasks/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright 2023 jacqueline <me@jacqueline.id.au> # # SPDX-License-Identifier: GPL-3.0-only -idf_component_register(SRCS "tasks.cpp" INCLUDE_DIRS "." REQUIRES "span" "memory") +idf_component_register(SRCS "tasks.cpp" INCLUDE_DIRS "." REQUIRES "memory") target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS}) diff --git a/src/tasks/tasks.cpp b/src/tasks/tasks.cpp index aa382655..d3937c68 100644 --- a/src/tasks/tasks.cpp +++ b/src/tasks/tasks.cpp @@ -33,12 +33,12 @@ auto Name<Type::kAudioConverter>() -> std::pmr::string { } template <Type t> -auto AllocateStack() -> cpp::span<StackType_t>; +auto AllocateStack() -> std::span<StackType_t>; // Decoders often require a very large amount of stack space, since they aren't // usually written with embedded use cases in mind. template <> -auto AllocateStack<Type::kAudioDecoder>() -> cpp::span<StackType_t> { +auto AllocateStack<Type::kAudioDecoder>() -> std::span<StackType_t> { constexpr std::size_t size = 20 * 1024; static StackType_t sStack[size]; return {sStack, size}; @@ -46,14 +46,14 @@ auto AllocateStack<Type::kAudioDecoder>() -> cpp::span<StackType_t> { // LVGL requires only a relatively small stack. Lua's stack is allocated // separately. template <> -auto AllocateStack<Type::kUi>() -> cpp::span<StackType_t> { +auto AllocateStack<Type::kUi>() -> std::span<StackType_t> { constexpr std::size_t size = 14 * 1024; static StackType_t sStack[size]; return {sStack, size}; } template <> // PCM conversion and resampling uses a very small amount of stack. -auto AllocateStack<Type::kAudioConverter>() -> cpp::span<StackType_t> { +auto AllocateStack<Type::kAudioConverter>() -> std::span<StackType_t> { constexpr std::size_t size = 4 * 1024; static StackType_t sStack[size]; return {sStack, size}; @@ -63,7 +63,7 @@ auto AllocateStack<Type::kAudioConverter>() -> cpp::span<StackType_t> { // cases, where large stack usage isn't so much of a concern. It therefore uses // an eye-wateringly large amount of stack. template <> -auto AllocateStack<Type::kBackgroundWorker>() -> cpp::span<StackType_t> { +auto AllocateStack<Type::kBackgroundWorker>() -> std::span<StackType_t> { std::size_t size = 64 * 1024; return {static_cast<StackType_t*>(heap_caps_malloc(size, MALLOC_CAP_SPIRAM)), size}; diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index 47f26837..566b5706 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -11,6 +11,7 @@ #include <future> #include <memory> #include <memory_resource> +#include <span> #include <string> #include "esp_heap_caps.h" @@ -19,7 +20,6 @@ #include "freertos/projdefs.h" #include "freertos/queue.h" #include "freertos/task.h" -#include "span.hpp" namespace tasks { @@ -46,7 +46,7 @@ enum class Type { template <Type t> auto Name() -> std::pmr::string; template <Type t> -auto AllocateStack() -> cpp::span<StackType_t>; +auto AllocateStack() -> std::span<StackType_t>; template <Type t> auto Priority() -> UBaseType_t; @@ -56,7 +56,7 @@ template <Type t> auto StartPersistent(const std::function<void(void)>& fn) -> void { StaticTask_t* task_buffer = static_cast<StaticTask_t*>(heap_caps_malloc( sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); - cpp::span<StackType_t> stack = AllocateStack<t>(); + std::span<StackType_t> stack = AllocateStack<t>(); xTaskCreateStatic(&PersistentMain, Name<t>().c_str(), stack.size(), new std::function<void(void)>(fn), Priority<t>(), stack.data(), task_buffer); @@ -67,7 +67,7 @@ auto StartPersistent(BaseType_t core, const std::function<void(void)>& fn) -> void { StaticTask_t* task_buffer = static_cast<StaticTask_t*>(heap_caps_malloc( sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); - cpp::span<StackType_t> stack = AllocateStack<t>(); + std::span<StackType_t> stack = AllocateStack<t>(); xTaskCreateStaticPinnedToCore(&PersistentMain, Name<t>().c_str(), stack.size(), new std::function<void(void)>(fn), Priority<t>(), stack.data(), task_buffer, core); |
