LCOV - code coverage report
Current view: top level - src/MIDI_Interfaces/BLEMIDI/Util - ESP32Threads.hpp (source / functions) Hit Total Coverage
Test: 3a807a259ebe0769dd942f7f612dca5273937539 Lines: 2 2 100.0 %
Date: 2024-03-24 17:16:54 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #ifdef ESP32
       4             : #include <esp_pthread.h>
       5             : #endif
       6             : 
       7             : #include <Settings/NamespaceSettings.hpp>
       8             : 
       9             : BEGIN_CS_NAMESPACE
      10             : 
      11             : struct ScopedThreadConfig {
      12             : #ifdef ESP32
      13             :     ScopedThreadConfig(size_t stack_size, size_t priority, bool inherit_cfg,
      14             :                        const char *thread_name,
      15             :                        int pin_to_core = tskNO_AFFINITY) {
      16             :         memset(&previousConfig, 0, sizeof(previousConfig));
      17             :         hadPreviousConfig = esp_pthread_get_cfg(&previousConfig) == ESP_OK;
      18             :         esp_pthread_cfg_t cfg = previousConfig;
      19             :         cfg.stack_size = stack_size;
      20             :         cfg.prio = priority;
      21             :         cfg.inherit_cfg = inherit_cfg;
      22             :         cfg.thread_name = thread_name;
      23             :         cfg.pin_to_core = pin_to_core;
      24             :         esp_pthread_set_cfg(&cfg);
      25             :     }
      26             : 
      27             :     ~ScopedThreadConfig() {
      28             :         if (hadPreviousConfig)
      29             :             esp_pthread_set_cfg(&previousConfig);
      30             :     }
      31             : 
      32             :   private:
      33             :     bool hadPreviousConfig;
      34             :     esp_pthread_cfg_t previousConfig;
      35             : #else
      36          28 :     ScopedThreadConfig(size_t stack_size, size_t priority, bool inherit_cfg,
      37             :                        const char *thread_name, int pin_to_core = -1) {
      38             :         (void)stack_size;
      39             :         (void)priority;
      40             :         (void)inherit_cfg;
      41             :         (void)thread_name;
      42             :         (void)pin_to_core;
      43          28 :     }
      44             : #endif
      45             : };
      46             : 
      47             : END_CS_NAMESPACE

Generated by: LCOV version 1.15