fix (NetworkEvents lib) remove checks for duplicated event handlers#10376
fix (NetworkEvents lib) remove checks for duplicated event handlers#10376me-no-dev merged 8 commits intoespressif:masterfrom
Conversation
…llbacks removing event callback via std::function pointer does not work as expected for lambdas (issue espressif#10365) here mark NetworkEvents::removeEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX) as deprecated in favor of removing by callback's id for NetworkEvents::onEvent remove checking for dublicate event handler, this does not work for lambdas too remove NetworkEvents::find methods as unnecessary move cbEventList container inside the class declare NetworkEventCbList_t as a cpp struct with constructor, allows using std::vector.emplace() when adding new items to container optimize NetworkEvents::remove() calls to use erase-remove idiom for std::vector
prevent checkForEvent loop to be callable from outside the task's thread
- rename NetworkEvents::cbEventList as private member NetworkEvents_cbEventList - NetworkEvents::getStatusBits() add const qualifier - turn statics into constexpr - add indexes to enum::arduino_event_id_t to make events indexing consistent for SOCs with/without WiFi also leave some index gaps to minimize renumbering on adding new events - add doxygen help to NetworkEvents:: methods - declare NetworkEvents::eventName() as static, that could be used without creating class scope - potential mem leak in postEvent
👋 Hello vortigont, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
Test Results 56 files 56 suites 4m 11s ⏱️ Results for commit ab1d55d. ♻️ This comment has been updated with latest results. |
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…tions provide thread safety for dual core SoCs since std::mutex brings additional componetns of libstdc++ lib it impacts resulting image size significantly (around 50k) Might be enabled on-demand if thread-safety is required
28b93b9 to
1a2d988
Compare
SuGlider
left a comment
There was a problem hiding this comment.
LGTM!
@vortigont - thanks for the good contribution!
|
There are some spelling errors: https://github.com/espressif/arduino-esp32/actions/runs/11498055926/job/32003053726?pr=10376#step:8:25 |
A refactoring for
NetworkEventsclassThis fixes #10365 issue and supersedes #10337, it removes pointer comparison checks for function pointer handlers but adds more safety to the code working with callback handlers container.
std::functionpointer, it does not work as expected for lambdasNetworkEvents::removeEvent(NetworkEventFuncCb)as deprecated in favor of removing by callback's idNetworkEvents::onEventremove checking for duplicate event handler, this does not work for lambdas tooNetworkEvents::findmethods as unnecessary in favor of usingstditeratorsNetworkEventsclassNetworkEventCbList_tas a cpp struct with constructor, allows usingstd::vector.emplace()when adding new items to containerNetworkEvents::remove()calls to use erase-remove idiom forstd::vectorNetworkEventsclassarduino_event_id_tto make events indexing consistent for SOCs with/without WiFialso leave some index gaps to minimize renumbering on adding new events
NetworkEvents::methodsNetworkEvents::eventName()as static, that could be used without creating class scopepostEvent()