Skip to content
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

Clean up confusion with deprecated constructors and callbacks in thread-spawning functions #2549

Merged
merged 5 commits into from Sep 9, 2016

Conversation

geky
Copy link
Contributor

@geky geky commented Aug 25, 2016

Note: This is currently dependent on #2496 and will be updated based on the discussion in that pr. Here are the new commits:
756a090 Added explicit void specialization in callbacks
022f821 Rewrote thread deprecation notices to help migration

User feedback indicated that the previous deprecation notices were confusing. Additionally, limitations on implicit casts for callback arguments tripped up attempts at migrating from the old style of thread spawning and led to a poor user experience.

In an effort to remedy this:

  1. The callback class was updated to accept explicit void pointers, allowing implicit casts to void pointer, and avoids requiring users to change the argument types of their code.
  2. The deprecation notices were updated to emphasize the replacement functions, and examples of correct usage were added in the doxygen.

cc @0xc0170, @pan-, @maclobdell

@geky geky changed the title Clean up issues with deprecated constructors and callbacks in thread-spawning functions Clean up confusion with deprecated constructors and callbacks in thread-spawning functions Aug 25, 2016
Additionally, the following changes were don to avoid combinatorial
explosion in function overloads as a result of adding cv-qualifiers:
- Added convenience function for inferred type
- Deprecated callback overloads qhere cv-qualifiers are not scalable

Supported overloads:
callback(void (*f)(A...));
callback(const Callback<R(A...)> &);
callback(T *t,                void (*f)(T*, A...));
callback(const T *t,          void (*f)(const T*, A...));
callback(volatile T *t,       void (*f)(volatile T*, A...));
callback(const volatile T *t, void (*f)(const volatile T*, A...));
callback(T *t,                void (T::*f)(A...));
callback(const T *t,          void (T::*f)(A...) const);
callback(volatile T *t,       void (T::*f)(A...) volatile);
callback(const volatile T *t, void (T::*f)(A...) const volatile);
- Marked `call` and `operator()` functions as const
- Moved to static_cast for internal function pointer to avoid losing
  compiler checked const-safety
- Added test for `operator=` with non-callback types
- Moved from zero-cast to value-initializer when callback is null
- Added `operator==` and `operator!=`
- Removed special handling of null callback
- Replicated doxygen to all overloads
- Added correct nops where uninitialized callbacks are called
- Added assertion for null callback
- Removed copy-constructor from callback constructor
As the templated tests grew, the resulting binary exceeded a
flash size of 64K. This caused the test to incorrectly fail on
small devices.

Moved and split into the following:
TESTS/mbed_functional/callback
TESTS/mbed_functional/callback_small
TESTS/mbed_functional/callback_big
TESTS/mbed_functional/functionpointer
One limitation of C++ is that implicit casts do not occur when
matching template overloads, as a consequence the callback's
argument type requires a strict match.

Unfortunately, the prevents the previously common pattern of using
void pointers as function arguments, causing unnecessary problems
for users porting code.

        Thing *t;
        void doit(void *p) { blablabla }

        Callback<void()> cb(t, doit);

To avoid this, explicit overloads on void pointers were added. This
avoids a template expansion, and allows the implicit cast to occur
as the user would expect.
User feedback indicated that the previous deprecation notices
were confusing and mislead migration from the old style of thread
spawning.

The deprecation notices were updated to emphasize the replacement
functions, and examples of correct usage were added in the doxygen.
@sg-
Copy link
Contributor

sg- commented Sep 8, 2016

/morph test

@sg-
Copy link
Contributor

sg- commented Sep 8, 2016

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@sg- sg- removed the needs: review label Sep 8, 2016
@mbed-bot
Copy link

mbed-bot commented Sep 9, 2016

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 790

All builds and test passed!

@mbed-bot
Copy link

mbed-bot commented Sep 9, 2016

[Build 879]
FAILURE: Something went wrong when building and testing.

@sg- sg- merged commit 3bb149c into ARMmbed:master Sep 9, 2016
artokin pushed a commit to artokin/mbed-os that referenced this pull request Jan 22, 2021
…..91f3ff6

91f3ff6 Merge branch 'release_internal' into release_external
3999b6e Iotthd 4495 (ARMmbed#2556)
90c3263 RPL Prefix handling update:
f761409 Close Nanostack v12.8.0 ChangeLog (ARMmbed#2549)

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 91f3ff6
artokin pushed a commit to artokin/mbed-os that referenced this pull request Apr 20, 2021
…..0903b81

0903b81 Merge remote-tracking branch 'origin/release_internal' into release_external
51429c9 FHSS WS: api function to set TX allowance level (ARMmbed#2612)
01b1188 Fix Child NUD with long ARO registrations
20b49ce Optimize out of memory handler to remove more memory in EF mode
f1b03bc FHSS WS: Allow transmitting unicast frames on broadcast channel for 1st hop node in EF mode (ARMmbed#2609)
2f5e5e2 Generic forwarding callback and EF state enabler for Wi-SUN BBR.
007dfa2 Allow transmitting on RX slot for 1st hop device in expedited forwarding mode (ARMmbed#2607)
6524872 Implemented FHSS expedited forwarding mode (ARMmbed#2606)
91e0b4c QoS traffic class documentation update.
3acd3a4 Fix warnings found by cppcheck (ARMmbed#2605)
d2f5347 MPX and MAC API update
7310cc0 MAC: "CCA fail on RX" event for TX done callback (ARMmbed#2602)
cd109c3 Clear Ack tx and tx process in MAC reset (ARMmbed#2601)
45504fd Optimize stagger based on uptime and startup type
ed5209e Iotthd 4584 (ARMmbed#2599)
60726dc Fixed blacklisting overflow (ARMmbed#2597)
23334b7 Added support for High Priority forward state
3ec2a2c Corrected freed memory access on incoming EAPOL handling
aecadc4 Fixed delayed interrupt (ARMmbed#2596)
1fca2c1 CCA backoffs max to 9 (ARMmbed#2595)
f3d2fa1 Added API function to get neighbor table information from Wi-SUN
3bb089b Validate randomized fixed channel (ARMmbed#2592)
70743a1 MAC stabilisation fixes (ARMmbed#2591)
e936a26 Reduce periodic DNS traces
a45fe3f Improved CSMA-CA logic for Wi-SUN (ARMmbed#2585)
56b7735 improved Wi-SUN stack statistics added
e656190 Wi-SUN neighbour allocate update
799f837 Added address check for Whiteboard address ADD
0b6caa3 Wi-SUN network timing parameter tuning
4921465 Supress warnings
f5cecd7 Enable external connection for routers
e129a0a Added LLC EAPOL temporary neighbor remove when authentication completes (ARMmbed#2583)
fa20fb9 Added calculation of LLC and LLC EAPOL message queue average (ARMmbed#2582)
7f7c01a Added retry traces to authenticator EAP-TLS, 4WH, and GKH
a87646d On startup deletes NVM GTKs if EUI-64 has been changed (ARMmbed#2576)
509a6f9 Add CI commands to PR template (ARMmbed#2579)
eb6a4f7 Change stagger calculation to give more bandwidth to application
82f1d54 Wi-SUN bpptstrap clear destination cache at discovery phase.
71b0588 Destination cache update:
f92c385 Enabled PMTU timeout to destination cache after used.
957b358 DHCP server and Agent relay update
25b9124 Merge remote-tracking branch 'origin/release_internal' into release_external
c825b04 Corrected covery warning on delay_us multiplication
be63bbb Updated changelog
77a76c7 Corrected nw size set on automatic mode
65e6c2d Updated unit tests
16e3402 Added waiting queue to EAPOL authentications to Border Router
b9c0b7d Wi-SUN border router starts faster in static configuration
2f427e1 Local repair start and stop clear advertised_dodag_membership_since_last_repair when state is updated.
0a01ab1 RPL dio send update
dd39963 Wi-SUN Border router uses Static address as DODAGID
7a3c833 Additional check to detect parent connection problem
ffe48c9 WS management: domain configuration functions implemented (ARMmbed#2567)
5e9ac4e Added new Callback to RPL indicate Multicast DIS received from RPL Parent
85b949e Bootstrap and EAPOL treats all MAC TX failure causes similarly
b57d9bc Add support for anonymous addressing in Wi-SUN border router (ARMmbed#2565)
7400c8b CFG: API for PHY mode id and channel plan id get & validate (ARMmbed#2564)
2832fe8 Added Socket reference limitter
890aad1 Wi-SUN MTU size update and IPv6 minium MTU routing skip
3ad28c1 Added throttling of number of simultaneous EAPOL authentications
0b84299 Source route handler call Wi-Sun border router alive function.
c8343b1 Added support for dynamic RPL default lifetime
d258068 Iotthd 4478 (ARMmbed#2560)
7ca6c24 Enable and modify memory limits for packet receiving
e2b028d Close CHANGELOG.md for v12.8.1 (ARMmbed#2557)
91f3ff6 Merge branch 'release_internal' into release_external
3999b6e Iotthd 4495 (ARMmbed#2556)
90c3263 RPL Prefix handling update:
f761409 Close Nanostack v12.8.0 ChangeLog (ARMmbed#2549)
f8ae0e9 Merge remote-tracking branch 'origin/release_internal' into release_external
3275f83 Added support for handle RPL hop by Hop sender rank 0.
d62c589 Activated RPL force tunnel for wi-sun.
3e1064a RPL tunnel force functionality update
3207e5c RPL parent select timer random update from 1.0-1.2 to 1.0-1.5.
bc09cba MAC Ack wait fixed for OFDM (ARMmbed#2552)
5106b1d Fixed unused variable and function warnings.
4096c1a Wi-SUN bootstrap support RPL poison from Connected state to Discovery
66378d1 RPL Poison update

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 0903b81
artokin pushed a commit to artokin/mbed-os that referenced this pull request Apr 21, 2021
…183d87..0903b81

0903b81 Merge remote-tracking branch 'origin/release_internal' into release_external
51429c9 FHSS WS: api function to set TX allowance level (ARMmbed#2612)
01b1188 Fix Child NUD with long ARO registrations
20b49ce Optimize out of memory handler to remove more memory in EF mode
f1b03bc FHSS WS: Allow transmitting unicast frames on broadcast channel for 1st hop node in EF mode (ARMmbed#2609)
2f5e5e2 Generic forwarding callback and EF state enabler for Wi-SUN BBR.
007dfa2 Allow transmitting on RX slot for 1st hop device in expedited forwarding mode (ARMmbed#2607)
6524872 Implemented FHSS expedited forwarding mode (ARMmbed#2606)
91e0b4c QoS traffic class documentation update.
3acd3a4 Fix warnings found by cppcheck (ARMmbed#2605)
d2f5347 MPX and MAC API update
7310cc0 MAC: "CCA fail on RX" event for TX done callback (ARMmbed#2602)
cd109c3 Clear Ack tx and tx process in MAC reset (ARMmbed#2601)
45504fd Optimize stagger based on uptime and startup type
ed5209e Iotthd 4584 (ARMmbed#2599)
60726dc Fixed blacklisting overflow (ARMmbed#2597)
23334b7 Added support for High Priority forward state
3ec2a2c Corrected freed memory access on incoming EAPOL handling
aecadc4 Fixed delayed interrupt (ARMmbed#2596)
1fca2c1 CCA backoffs max to 9 (ARMmbed#2595)
f3d2fa1 Added API function to get neighbor table information from Wi-SUN
3bb089b Validate randomized fixed channel (ARMmbed#2592)
70743a1 MAC stabilisation fixes (ARMmbed#2591)
e936a26 Reduce periodic DNS traces
a45fe3f Improved CSMA-CA logic for Wi-SUN (ARMmbed#2585)
56b7735 improved Wi-SUN stack statistics added
e656190 Wi-SUN neighbour allocate update
799f837 Added address check for Whiteboard address ADD
0b6caa3 Wi-SUN network timing parameter tuning
4921465 Supress warnings
f5cecd7 Enable external connection for routers
e129a0a Added LLC EAPOL temporary neighbor remove when authentication completes (ARMmbed#2583)
fa20fb9 Added calculation of LLC and LLC EAPOL message queue average (ARMmbed#2582)
7f7c01a Added retry traces to authenticator EAP-TLS, 4WH, and GKH
a87646d On startup deletes NVM GTKs if EUI-64 has been changed (ARMmbed#2576)
509a6f9 Add CI commands to PR template (ARMmbed#2579)
eb6a4f7 Change stagger calculation to give more bandwidth to application
82f1d54 Wi-SUN bpptstrap clear destination cache at discovery phase.
71b0588 Destination cache update:
f92c385 Enabled PMTU timeout to destination cache after used.
957b358 DHCP server and Agent relay update
25b9124 Merge remote-tracking branch 'origin/release_internal' into release_external
c825b04 Corrected covery warning on delay_us multiplication
be63bbb Updated changelog
77a76c7 Corrected nw size set on automatic mode
65e6c2d Updated unit tests
16e3402 Added waiting queue to EAPOL authentications to Border Router
b9c0b7d Wi-SUN border router starts faster in static configuration
2f427e1 Local repair start and stop clear advertised_dodag_membership_since_last_repair when state is updated.
0a01ab1 RPL dio send update
dd39963 Wi-SUN Border router uses Static address as DODAGID
7a3c833 Additional check to detect parent connection problem
ffe48c9 WS management: domain configuration functions implemented (ARMmbed#2567)
5e9ac4e Added new Callback to RPL indicate Multicast DIS received from RPL Parent
85b949e Bootstrap and EAPOL treats all MAC TX failure causes similarly
b57d9bc Add support for anonymous addressing in Wi-SUN border router (ARMmbed#2565)
7400c8b CFG: API for PHY mode id and channel plan id get & validate (ARMmbed#2564)
2832fe8 Added Socket reference limitter
890aad1 Wi-SUN MTU size update and IPv6 minium MTU routing skip
3ad28c1 Added throttling of number of simultaneous EAPOL authentications
0b84299 Source route handler call Wi-Sun border router alive function.
c8343b1 Added support for dynamic RPL default lifetime
d258068 Iotthd 4478 (ARMmbed#2560)
7ca6c24 Enable and modify memory limits for packet receiving
e2b028d Close CHANGELOG.md for v12.8.1 (ARMmbed#2557)
91f3ff6 Merge branch 'release_internal' into release_external
3999b6e Iotthd 4495 (ARMmbed#2556)
90c3263 RPL Prefix handling update:
f761409 Close Nanostack v12.8.0 ChangeLog (ARMmbed#2549)
f8ae0e9 Merge remote-tracking branch 'origin/release_internal' into release_external
3275f83 Added support for handle RPL hop by Hop sender rank 0.
d62c589 Activated RPL force tunnel for wi-sun.
3e1064a RPL tunnel force functionality update
3207e5c RPL parent select timer random update from 1.0-1.2 to 1.0-1.5.
bc09cba MAC Ack wait fixed for OFDM (ARMmbed#2552)
5106b1d Fixed unused variable and function warnings.
4096c1a Wi-SUN bootstrap support RPL poison from Connected state to Discovery
66378d1 RPL Poison update

git-subtree-dir: connectivity/nanostack/sal-stack-nanostack
git-subtree-split: 0903b81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants