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

Implement EXCHANGE_LIFETIME for message ID generation #8

Merged
merged 28 commits into from
Sep 26, 2023

Conversation

deavmi
Copy link
Owner

@deavmi deavmi commented Sep 25, 2023

Purpose

This is to implement the EXCHANGE_LIFETIME mechanism which posits an upper bound on the lifetime of validity for a message ID, in which a message ID is still considered "in use" but over which it is available for re-usage. If it is "in use" then we must generate the next available free one.

Todo ✍️

  • Lifetime mechanism and message ID generation
  • Switch to newMid2()
    • In future, onNoNewMessages() can perform a clean up as we might have a leaky memory moment if we just constantly reuse first entry and never clean out the others - we can make this configurable so as to also not always reallocate new Stopwatch instances
  • Deprecate newMid()
    • I want to test out expiration

- Added `EXCHANGE_LIFETIME` and made it very high for starters
- Added `fineNextFree`() and `isPresent()`
- Documented
- `newMid2()` now uses `findNextFree()`
- Fixed bug whereby we didn't register the new found message id
- Switched to using `newMid2()` in `doRequest(CoapRequestBuilder)`
@deavmi deavmi self-assigned this Sep 25, 2023
@deavmi deavmi added the enhancement New feature or request label Sep 25, 2023
@deavmi deavmi changed the title Feature/exchange lifetime Implement EXCHANGE_LIFETIME for message ID generation Sep 25, 2023
- Set time to 10 milliseconds (for now)
- Start the stopwatch
- Tested
- Added a unittest for `isPresent!(T)(T[] values, T value)`
- Added a unittest for `findNextFree!(T)(T[] values)`
- Documented method
- Documented method
@deavmi
Copy link
Owner Author

deavmi commented Sep 25, 2023

Seems like it is working - more testing needed though.

- Added a FIXME
- Added missing documentation
- Added missing documentation
- Cleaned up
- Added missing documentation
- Fixed unit test for `flip!(T)(T)`
- Removed duplicate test
@deavmi deavmi mentioned this pull request Sep 25, 2023
7 tasks
- Added `setExchangeLifetime(Duration)`

CoapClient (unittests)

- Manually set the exchange lifetime
- Unset for now
- Set `EXCHANGE_LIFETIME` high enough to not reuse message IDs
- Cleaned up `newMid2()`
- Removed `newMid()`
- Removed old `rollingMid`
- Renamed mutex for `mids`
- Cleaned up imports
@deavmi
Copy link
Owner Author

deavmi commented Sep 26, 2023

Looks good to me ✔️

@deavmi
Copy link
Owner Author

deavmi commented Sep 26, 2023

Merging...

@deavmi deavmi merged commit 481afbb into master Sep 26, 2023
2 of 4 checks passed
@deavmi
Copy link
Owner Author

deavmi commented Sep 26, 2023

Merged ✔️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant