refactor(core): value-type GenId, extendable ObjectId, hidden ObjectPool - #77
Merged
Conversation
- GenId<T>: drop virtual dtor (was a vtable-bearing value type), default copy/move, add constexpr/noexcept, expose public id/gen members - fix(GenId): record last generation in drop() so recycled ids get strictly increasing generations (ABA-safe); old code cycled 1<->2 - ObjectId: change from `using` alias to class deriving from GenId<ObjectIdTag>, leaving an extension point for domain methods - UniqueObject: reset source id/gen on move so a moved-from handle cannot release a still-owned object (previously masked by GenId's null-out move) - fix: add missing std::forward<Args> template args in ObjectPool::create and UniqueObject::create
- UniqueObject::create<T> now only does new T in the header and delegates id allocation/registration to a private from_raw_ptr() defined in the .cpp, so unique_object.hpp no longer includes the internal core/object_pool.hpp - ObjectPool: replace the create<T> template with a non-template acquire(Object*) that mints an id and registers the object - value.cpp: add explicit object_pool.hpp include (previously got ObjectPool transitively via unique_object.hpp) - test_value.cpp: use UniqueObject::create in place of the removed ObjectPool::create in the disabled test bodies
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.
Summary
Series of core refactors around object identity and object-pool ownership:
destructor, default copy/move, add constexpr/noexcept; expose
id/genas public members (math-type style)
IdAllocator::drop()now records thelast-used generation so recycled ids get strictly increasing generations
instead of cycling between 1 and 2
using ObjectId = GenId<ObjectIdTag>to a class deriving fromGenId<ObjectIdTag>with an extension point; addedderef()/deref_as<T>()id so it can no longer release an object still owned by the moved-to
handle (previously masked by GenId's null-out move)
UniqueObject::create<T>onlyperforms
new Tin the header and delegates id allocation/registrationto a private
from_raw_ptr();ObjectPool::create<T>replaced by anon-template
acquire(Object*). Public headers no longer include internalsrc/coreheadersstd::forward<Args>missing template arguments inObjectPool::create/UniqueObject::create