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

Dereg individual #226

Merged
merged 31 commits into from
Apr 17, 2023
Merged

Dereg individual #226

merged 31 commits into from
Apr 17, 2023

Conversation

forwardpointer
Copy link
Contributor

@forwardpointer forwardpointer commented Apr 13, 2023

Type

  • Bug fix
  • Feature addition
  • Feature update
  • Breaking change
  • Non-functional change
  • Documentation
  • Infrastructure

Goals

Allow the deregistration of individual callbacks.

Technical Details

Since some callback function signatures are ambiguous, I decided to make separate types for each callback. These types are used internally by UwbConnector to keep track of what's what.

On the client side (i.e. UwbDevice and UwbSession), things largely stayed the same. They still fill out the structure of device callbacks or session callbacks, which they pass into Register[Device|Session]EventCallbacks. However, now those functions return a structure containing weak_ptr to the callback tokens corresponding to each of the callbacks they registered. If the client leaves some callbacks out of the structure, then the callback token for those callbacks will be nullptr (and the UwbConnector won't have added that token to its internal storage). The structure containing all session or device callbacks is nice to have in the interface because it allows the client to unambiguously label the callbacks as what they are, without needing to be aware of all the internal types UwbConnector uses to keep track.

Test Results

Regression tests pass

Reviewer Focus

Are there any other approaches to this that avoid the problem of having to define a type for each callback?

Future Work

  • Actually call the deregistration in the TODO places
  • Support recursive locks so that the callback can deregister itself.

Checklist

  • Build target all compiles cleanly.
  • clang-format and clang-tidy deltas produced no new output.
  • Newly added functions include doxygen-style comment block.

@forwardpointer forwardpointer marked this pull request as ready for review April 14, 2023 01:03
@forwardpointer forwardpointer requested a review from a team as a code owner April 14, 2023 01:03
@abeltrano
Copy link
Contributor

Reviewer Focus

Are there any other approaches to this that avoid the problem of having to define a type for each callback?

An explicit type for each callback seems fine to me since there are actually different callback prototypes, so we really can't avoid them.

windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
Copy link
Contributor

@abeltrano abeltrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really well done. I added some comments with suggestions for consolidating stuff and simplifying the callback instances themselves, but otherwise this looks great.

lib/uwb/include/uwb/UwbRegisteredCallbacks.hxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
corbin-phipps
corbin-phipps previously approved these changes Apr 14, 2023
corbin-phipps
corbin-phipps previously approved these changes Apr 14, 2023
@forwardpointer
Copy link
Contributor Author

I just ran a regression test on the basic ranging scenario, and it passes. So it should be ready for merging now

windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
windows/devices/uwb/UwbConnector.cxx Show resolved Hide resolved
@forwardpointer forwardpointer merged commit 086ab29 into develop Apr 17, 2023
@forwardpointer forwardpointer deleted the dereg_individual branch April 17, 2023 21:37
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.

3 participants