Skip to content

Commit

Permalink
Merge pull request #8 from Tasssadar/rtos
Browse files Browse the repository at this point in the history
fix: freeRTOSEventQueue queue draining on shutdown
  • Loading branch information
cubicap authored Jul 10, 2024
2 parents 8a88994 + cdb2e3f commit 742d8fb
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 742d8fb

Please sign in to comment.