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

Add internal thread-safe dictionary wrapper #115

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

nathandud
Copy link
Contributor

@nathandud nathandud commented Mar 6, 2025

To address issue #114, this PR includes an internal wrapper for Dictionary called CBMDictionary.

Some notes:

  • The CBMDictionary does not attempt to include every possible dictionary operation - only what is needed by the current implementation of CoreBluetoothMock.
  • The private queue uses the default quality-of-service. I believe this is sufficient.

Running the same unit test in #114 100,000 times repeatedly passes successfully:

image

Testing the performance of CBMCentralManagerMock.simulatePeripherals([device]) with the CBMDictionary was promising. In 100 tests, the average time:

  • CBMDictionary: 46.71 microseconds
  • Dictionary (Current): 46.04 microseconds

@CLAassistant
Copy link

CLAassistant commented Mar 6, 2025

CLA assistant check
All committers have signed the CLA.

@philips77 philips77 self-requested a review March 7, 2025 13:33
Copy link
Member

@philips77 philips77 left a comment

Choose a reason for hiding this comment

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

Great job!

@philips77 philips77 merged commit 3718165 into NordicSemiconductor:main Mar 10, 2025
1 check passed
@philips77
Copy link
Member

Hi, any objections of making CBMDictionary internal, or you'd prefer to expose it?

@nathandud
Copy link
Contributor Author

nathandud commented Mar 11, 2025

@philips77 No objections on my end! I didn't add the internal keyword because it is internal by default but I see no issue with making it explicit.

@philips77
Copy link
Member

Released in 1.0.0.

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