Skip to content

mw/com: Add ReferenceToMoveable[Owner] and remove updating of service elems in SkeletonBase#572

Open
bemerybmw wants to merge 3 commits into
mainfrom
brem_add_non_movable_ref
Open

mw/com: Add ReferenceToMoveable[Owner] and remove updating of service elems in SkeletonBase#572
bemerybmw wants to merge 3 commits into
mainfrom
brem_add_non_movable_ref

Conversation

@bemerybmw

Copy link
Copy Markdown
Contributor

Depends-on: #559

@bemerybmw bemerybmw changed the title mw/com: Add ReferenceToMoveable[Owner] and remove updating of service elems in Skeleton mw/com: Add ReferenceToMoveable[Owner] and remove updating of service elems in SkeletonBase Jun 19, 2026
@bemerybmw bemerybmw force-pushed the brem_add_non_movable_ref branch from 8a2e139 to e1450e3 Compare June 19, 2026 07:10
Comment thread score/mw/com/impl/reference_to_moveable_owner.h Outdated
Comment thread score/mw/com/impl/reference_to_moveable_owner.h Outdated
@bemerybmw bemerybmw marked this pull request as ready for review June 19, 2026 08:12
@bemerybmw bemerybmw force-pushed the brem_add_non_movable_ref branch 2 times, most recently from 836dacd to a7c6369 Compare June 22, 2026 09:02
Comment thread score/mw/com/impl/reference_to_moveable.h
Comment thread score/mw/com/impl/reference_to_moveable.h Outdated
Comment thread score/mw/com/impl/reference_to_moveable.h Outdated
Comment thread score/mw/com/impl/reference_to_moveable.h
@bemerybmw bemerybmw force-pushed the brem_add_non_movable_ref branch 3 times, most recently from d0362a5 to c476b03 Compare June 24, 2026 13:04
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant