Optimize event loop resource size
The event loop queue and task stack size is optimized to be determined by config factors. Fixes #1083
This commit is contained in:
@@ -22,6 +22,24 @@
|
||||
|
||||
#include "relay_chn_core.h"
|
||||
|
||||
/*
|
||||
Determine the event loop's queue and task stack sizes depending on
|
||||
the configuration and memory requirements
|
||||
*/
|
||||
#if RELAY_CHN_ENABLE_TILTING == 1
|
||||
#define EVENT_QUEUE_BASE_SIZE 32
|
||||
#define EVENT_QUEUE_SIZE_BY_CHN 24
|
||||
#else
|
||||
#define EVENT_QUEUE_BASE_SIZE 16
|
||||
#define EVENT_QUEUE_SIZE_BY_CHN 12
|
||||
#endif
|
||||
|
||||
#define RELAY_CHN_EVENT_LOOP_QUEUE_SIZE \
|
||||
(EVENT_QUEUE_BASE_SIZE + (EVENT_QUEUE_SIZE_BY_CHN * RELAY_CHN_COUNT))
|
||||
|
||||
#define RELAY_CHN_EVENT_LOOP_TASK_STACK_SIZE \
|
||||
(2048 + (RELAY_CHN_EVENT_LOOP_QUEUE_SIZE * RELAY_CHN_COUNT))
|
||||
|
||||
|
||||
static const char *TAG = "RELAY_CHN_CORE";
|
||||
|
||||
@@ -99,10 +117,10 @@ esp_err_t relay_chn_init_timer(relay_chn_ctl_t *chn_ctl)
|
||||
static esp_err_t relay_chn_create_event_loop()
|
||||
{
|
||||
esp_event_loop_args_t loop_args = {
|
||||
.queue_size = RELAY_CHN_COUNT * 8,
|
||||
.queue_size = RELAY_CHN_EVENT_LOOP_QUEUE_SIZE,
|
||||
.task_name = "relay_chn_event_loop",
|
||||
.task_priority = ESP_TASKD_EVENT_PRIO - 1,
|
||||
.task_stack_size = 2048,
|
||||
.task_stack_size = RELAY_CHN_EVENT_LOOP_TASK_STACK_SIZE,
|
||||
.task_core_id = tskNO_AFFINITY
|
||||
};
|
||||
esp_err_t ret = esp_event_loop_create(&loop_args, &relay_chn_event_loop);
|
||||
|
||||
Reference in New Issue
Block a user