-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix (NetworkEvents lib) remove checks for duplicated event handlers #10376
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@vortigont - thanks for the good contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There are some spelling errors: https://github.com/espressif/arduino-esp32/actions/runs/11498055926/job/32003053726?pr=10376#step:8:25 |
A refactoring for
NetworkEvents
classThis 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::function
pointer, it does not work as expected for lambdasNetworkEvents::removeEvent(NetworkEventFuncCb)
as deprecated in favor of removing by callback's idNetworkEvents::onEvent
remove checking for duplicate event handler, this does not work for lambdas tooNetworkEvents::find
methods as unnecessary in favor of usingstd
iteratorsNetworkEvents
classNetworkEventCbList_t
as a cpp struct with constructor, allows usingstd::vector.emplace()
when adding new items to containerNetworkEvents::remove()
calls to use erase-remove idiom forstd::vector
NetworkEvents
classarduino_event_id_t
to 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()