Skip to content

refactor(core): value-type GenId, extendable ObjectId, hidden ObjectPool - #77

Merged
CoraBlack merged 7 commits into
gkit-org:mainfrom
CoraBlack:main
Aug 12, 2026
Merged

refactor(core): value-type GenId, extendable ObjectId, hidden ObjectPool#77
CoraBlack merged 7 commits into
gkit-org:mainfrom
CoraBlack:main

Conversation

@CoraBlack

Copy link
Copy Markdown
Contributor

Summary

Series of core refactors around object identity and object-pool ownership:

  • GenId → plain value type — drop the vtable-bearing virtual
    destructor, default copy/move, add constexpr/noexcept; expose id/gen
    as public members (math-type style)
  • Fix ABA generation bugIdAllocator::drop() now records the
    last-used generation so recycled ids get strictly increasing generations
    instead of cycling between 1 and 2
  • ObjectId is no longer an alias — changed from
    using ObjectId = GenId<ObjectIdTag> to a class deriving from
    GenId<ObjectIdTag> with an extension point; added deref() /
    deref_as<T>()
  • Fix UniqueObject move semantics — a moved-from handle now resets its
    id so it can no longer release an object still owned by the moved-to
    handle (previously masked by GenId's null-out move)
  • Hide ObjectPool implementationUniqueObject::create<T> only
    performs new T in the header and delegates id allocation/registration
    to a private from_raw_ptr(); ObjectPool::create<T> replaced by a
    non-template acquire(Object*). Public headers no longer include internal
    src/core headers
  • Fix std::forward<Args> missing template arguments in
    ObjectPool::create / UniqueObject::create
  • Documentation — full comments for the new/refactored public APIs

- 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
@CoraBlack
CoraBlack merged commit 47d6d2b into gkit-org:main Aug 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant