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

Callback Deregistration #224

Merged
merged 17 commits into from
Apr 12, 2023
Merged

Callback Deregistration #224

merged 17 commits into from
Apr 12, 2023

Conversation

forwardpointer
Copy link
Contributor

@forwardpointer forwardpointer commented Apr 11, 2023

Type

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

Goals

Allow the deregistration of callbacks

Technical Details

  • Every callback has an id, this map is stored in m_[session|device]EventCallbacksIdMap.
  • m_[session|device]EventCallbacks now stores the callback ids, not the callbacks themselves.
  • m_tokens holds the list of tokens so that the memory is not released when we return the tokens to the caller of the register callback functions

Test Results

  • the basic ranging scenario works

Reviewer Focus

Currently the interface maintains the invariant that m_tokens, m_[session|device]EventCallbacks, and m_[session|device]EventCallbacksIdMap are always in sync. However, this may result in a slow runtime for GetResolved[Session|Device]EventCallbacks(). Consider if relaxing that invariant makes sense.

Future Work

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 requested a review from a team as a code owner April 11, 2023 17:53
@forwardpointer forwardpointer changed the title Dereg Callback Deregistration Apr 11, 2023
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 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
abeltrano
abeltrano previously approved these changes Apr 12, 2023
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.

Just a few small suggestions and nit picks, but this is completely awesome 💯

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
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
corbin-phipps
corbin-phipps previously approved these changes Apr 12, 2023
Copy link
Contributor

@corbin-phipps corbin-phipps left a comment

Choose a reason for hiding this comment

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

Still some minor changes that could be made (such as changing return type of InsertDeviceEventCallback to std::weak_ptr), but nothing that affects functionality, so it seems good to go

@forwardpointer forwardpointer merged commit e8680f6 into develop Apr 12, 2023
@abeltrano abeltrano deleted the dereg branch May 2, 2023 05:54
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