retry_policy: replace all usages of Box<dyn RetryPolicy> with Arc<...>#1103
Merged
Lorak-mmk merged 2 commits intoscylladb:mainfrom Oct 24, 2024
Merged
retry_policy: replace all usages of Box<dyn RetryPolicy> with Arc<...>#1103Lorak-mmk merged 2 commits intoscylladb:mainfrom
Box<dyn RetryPolicy> with Arc<...>#1103Lorak-mmk merged 2 commits intoscylladb:mainfrom
Conversation
|
See the following report for details: cargo semver-checks output |
e2fbbf2 to
de6fde4
Compare
This way, it's easier to reuse retry policy for multiple execution profiles/statement configs - there is no need for additional allocation of Box.
Again, from now on we will prefer storing dyn RetryPolicy behind an Arc. There is no need for `clone_boxed` method anymore. Removed `impl Clone for Box<dyn RetryPolicy>`
de6fde4 to
c958c9b
Compare
5 tasks
wprzytula
reviewed
Oct 24, 2024
Comment on lines
+194
to
+195
| pub(crate) fn retry_policy() -> Arc<dyn RetryPolicy> { | ||
| Arc::new(DefaultRetryPolicy::new()) |
Collaborator
There was a problem hiding this comment.
We do lose something. Namely, Box has an optimisation which makes it not allocate anything for ZSTs, and Arc allocates always (its control block). However, I don't know if the optimisation is viable for Box<dyn Trait> with ZST inside.
wprzytula
approved these changes
Oct 24, 2024
Lorak-mmk
approved these changes
Oct 24, 2024
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This way, when user wants to reuse a retry policy in multiple places, there is no need for an additional allocation for Box (
RetryPolicy::clone_boxed).Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have provided docstrings for the public items that I want to introduce../docs/source/.[ ] I added appropriateFixes:annotations to PR description.