Skip to content

Commit

Permalink
fix: freeRTOSEventQueue queue draining on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasssadar committed Jul 10, 2024
1 parent 8a88994 commit cdb2e3f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main/espFeatures/freeRTOSEventQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ class FreeRTOSEventQueueFeature : public Next {
}
}

void drain() {
while(true) {
Event e;
if(xQueueReceive(_eventQueue, &e, 0) == pdFALSE) {
break;
}
}
}

void _scheduleImpl(auto&&... args) {
Event e(std::forward<decltype(args)>(args)...);
auto res = xQueueSend(_eventQueue, &e, portMAX_DELAY);
Expand Down Expand Up @@ -217,8 +226,7 @@ class FreeRTOSEventQueueFeature : public Next {
}

~FreeRTOSEventQueueFeature() {
notifyEventLoop();
while (dequeue(false)) {}
drain();
vQueueDelete(_eventQueue);
}
};

0 comments on commit cdb2e3f

Please sign in to comment.