-
Notifications
You must be signed in to change notification settings - Fork 3k
Callback extension and optimisation #12036
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
Conversation
This PR is based on and includes #12035, which deals with the breaking changes. Last 3 commits are the new content. |
c0ac861
to
9bd734f
Compare
@kjbracey-arm, thank you for your changes. |
9bd734f
to
ae7174b
Compare
Adjust wording to talk of Callback's being "empty", which is clearer than "null", and avoids thought of `NULL`. Add explicit note about using `nullptr` to reset. Preparation for ARMmbed/mbed-os#12036 - can be merged now as adjustments are valid for existing code.
Documentation for changes in ARMmbed/mbed-os#12036
c0d55f0
to
5e12858
Compare
I've posted a query about the GCC failure I saw working on this: https://answers.launchpad.net/gcc-arm-embedded/+question/686870 Although the failure has now apparently gone away since removing the full |
47677c5
to
6adc0a0
Compare
6adc0a0
to
3c67014
Compare
@kjbracey-arm looks like this also needs a rebase now ... |
@kjbracey-arm bump.... |
@AGlass0fMilk please review |
623b71d
to
587ebc5
Compare
587ebc5
to
c996b01
Compare
* Optimise clearing by adding `nullptr` overload. This overload means `Callback(NULL)` or `Callback(0)` will no longer work; users must use `Callback(nullptr)` or `Callback()`. * Optimise clearing by not clearing storage - increases code size of comparison, but that is extremely rare. * Reduce ROM used by trivial functors - share copy/destroy code. * Config option to force trivial functors - major ROM saving by eliminating the "operations" table. * Config option to eliminate comparison altogether - minor ROM saving by eliminating zero padding. * Conform more to `std::function` API.
c996b01
to
d09d854
Compare
Fixed up again - had pushed an incorrect version. Also fixed some problems I was having with breaking optimisation of the "trivial" mode. Long comment with links to explanations included. |
CI restarted |
Test run: SUCCESSSummary: 6 of 6 test jobs passed |
@ARMmbed/mbed-os-core @bulislaw Please review |
@@ -352,13 +352,15 @@ class NetworkInterface: public DNS { | |||
*/ | |||
void add_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb); | |||
|
|||
#if MBED_CONF_PLATFORM_CALLBACK_COMPARABLE | |||
/** Remove event listener from interface. | |||
* | |||
* Remove previously added callback from the handler list. | |||
* | |||
* @param status_cb The callback to unregister. | |||
*/ | |||
void remove_event_listener(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb); |
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.
Would be good to mention in doxygen that this function is not available if the callback_comparable flag is false, it may be not obvious if user looks at the doxygen and handbook only.
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.
I don't understand all of this C++ magic, but I trust Vincent's review :) The rest looks generally ok.
* Add docs for Callback config Documentation for changes in ARMmbed/mbed-os#12036 * "left set to false" -> "set to false" Make more ambiguous about default, as there's currently a pending change. Co-Authored-By: Irit Arkin <[email protected]> Co-authored-by: Irit Arkin <[email protected]>
Summary of changes
Extend
Callback
, and optimise it.Impact of changes
nullptr
overload.std::function
API.Force trivial functors by default to get major ROM saving.(now in Callback: Trivial default #12761)Migration actions required
nullptr
overload meansCallback(NULL)
orCallback(0)
will no longer work; users must useCallback(nullptr)
orCallback()
.If application code usesCallback
with a non-trivial functor, they will get a compilation error directing them to turn onplatform.callback-nontrivial
.Documentation
Pull request type
Test results
Reviewers
@pan-