mw/com: Add ReferenceToMoveable[Owner] and remove updating of service elems in SkeletonBase#572
Open
bemerybmw wants to merge 3 commits into
Open
mw/com: Add ReferenceToMoveable[Owner] and remove updating of service elems in SkeletonBase#572bemerybmw wants to merge 3 commits into
bemerybmw wants to merge 3 commits into
Conversation
8a2e139 to
e1450e3
Compare
bemerybmw
commented
Jun 19, 2026
bemerybmw
commented
Jun 19, 2026
836dacd to
a7c6369
Compare
bemerybmw
commented
Jun 23, 2026
bemerybmw
commented
Jun 23, 2026
bemerybmw
commented
Jun 23, 2026
a7c6369 to
f13d332
Compare
2 tasks
bemerybmw
commented
Jun 24, 2026
d0362a5 to
c476b03
Compare
In various places in our codebase, we have the issue in which we hand out a reference to a class which is moveable. If the class is moved, then we need to update this reference. E.g. SkeletonBase stores a map of references to its service elements. Each service element therefore must store a reference to the SkeletonBase and update the reference to itself when it's moved. The SkeletonBase must also update the reference to itself within each service element when it is moved. To avoid such complexity, this commit introduces a class EnableReferenceToMoveableFromThis which will be inherited by each service element. This stores a ReferenceToMoveable which is stored on the heap so a reference to it will never be invalidated. The ReferenceToMoveable will be updated when the service element is moved. A ReferenceToMoveable::Reference is provided to SkeletonBase from which it can get a reference to the service element, even if it's been moved. With this approach, the service element doesn't need to store a reference to the parent SkeletonBase so the parent SkeletonBase doesn't need to inform the service element when it moves.
Previously, each service element had to store a reference to the parent SkeletonBase so that it could update the reference to itself in the SkeletonBase when the service element was moved. This meant that both SkeletonBase and the service elements had to store references to each other. Keeping these references in a valid state during moving was complex and error prone. Each service element now inherits from EnableReferenceToMoveableFromThis which stores a ReferenceToMoveableOwner element which is updated when the service element moves. The SkeletonBase stores a ReferenceToMoveable::Reference to each service element, instead of a regular reference which is now always valid, regardless of moving of the SkeletonBase or service elements.
c476b03 to
38d5a26
Compare
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.
Depends-on: #559