Use atomics instead of static mut #2228
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
This is a follow-on from an early PR which eliminates the use of
unsafevia static mut by using atomic values instead.This adjusts the implementation of the max allocation bytes & serde human readable to use appropriate atomics for both.
This does have the added benefit of being able to adjust these values multiple time as the program runs, rather than setting them once.
Verifying this change
Tests have been adjusted slightly to use the
set_serde_human_readablefunctionDocumentation
I've updated the documentation to exclude the note about
Onceas this is no longer used and it is possible to update the allocation & human readable on the fly as your library runs.