载入中...
搜索中...
未找到
RuntimeRegistry.h
浏览该文件的文档.
70 explicit RuntimeSlotStore(OwnedInstanceDestroy destroy) noexcept : destroy_(destroy), ownerEpoch_(nextEpoch()) {}
175 [[nodiscard]] std::optional<std::uint32_t> findSlot(std::uint32_t index, std::uint32_t generation,
177 [[nodiscard]] static bool coordinatesValid(std::uint32_t index, std::uint32_t generation) noexcept;
179 [[nodiscard]] static std::optional<std::uint32_t> nextGeneration(std::uint32_t current) noexcept;
253 [[nodiscard]] Borrowed<T> borrow() const noexcept { return Borrowed<T>(get(), reference_.ownerEpoch); }
298 RuntimeObjectRegistry() : store_(std::make_unique<detail::RuntimeSlotStore>(&detail::ownedInstanceDestroy<T>)) {}
326 return eve::Result<Ref>::success(Ref{Handle(coordinates.index, coordinates.generation), store_->ownerEpoch()});
375 return eve::Result<RuntimePin<T, Tag>>::success(RuntimePin<T, Tag>(store_.get(), ref, object.value()));
std::vector< std::unique_ptr< ScriptClimbingEventSink > > retired
Definition ClimbingServices.cpp:188
Move-only, checked operation results for the common layer.
Handle-ref and borrowed observation types without the slot-map registry.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Process-local slot identity tagged by the registry that owns it.
Definition RuntimeHandle.h:116
Non-owning observation of a registry-owned object.
Definition RuntimeBorrow.h:27
Slot/generation registry whose objects are exclusively unique-owned.
Definition RuntimeRegistry.h:292
eve::Result< void > erase(Ref ref)
Destroys the object identified by a live handle.
Definition RuntimeRegistry.h:359
bool isStale(Ref ref) const noexcept
Reports whether a non-invalid handle can no longer resolve.
Definition RuntimeRegistry.h:379
std::uint64_t ownerEpoch() const noexcept
Returns the non-reusable lifetime epoch of this registry.
Definition RuntimeRegistry.h:417
void clear()
Invalidates all slots and releases every unique-owned object.
Definition RuntimeRegistry.h:414
void forEachLive(F &&visit)
Visit every live object with its slot index, in slot order.
Definition RuntimeRegistry.h:398
Borrowed< T > resolve(Ref ref) noexcept
Resolves a live object as a non-owning observation.
Definition RuntimeRegistry.h:340
Borrowed< const T > resolve(Ref ref) const noexcept
Const overload of resolve(); see the non-const form for its contract.
Definition RuntimeRegistry.h:347
eve::Result< RuntimePin< T, Tag > > pin(Ref ref)
Keeps one entry alive until the returned pin is released.
Definition RuntimeRegistry.h:372
RuntimeObjectRegistry(const RuntimeObjectRegistry &)=delete
eve::Result< Ref > emplace(Owned< T > object)
Transfers one unique-owned object into a fresh registry slot.
Definition RuntimeRegistry.h:314
void forEachLive(F &&visit) const
Read-only overload: the callback receives const T&.
Definition RuntimeRegistry.h:406
RuntimeObjectRegistry()
Creates an empty registry with a unique owner-lifetime epoch.
Definition RuntimeRegistry.h:298
RuntimeObjectRegistry(RuntimeObjectRegistry &&) noexcept=default
Constructs a RuntimeObjectRegistry.
RuntimeObjectRegistry & operator=(const RuntimeObjectRegistry &)=delete
RuntimeHandle< Tag > Handle
Definition RuntimeRegistry.h:294
RAII keep-alive for one RuntimeObjectRegistry entry.
Definition RuntimeRegistry.h:209
Borrowed< T > borrow() const noexcept
Borrows the pinned object together with its owner epoch.
Definition RuntimeRegistry.h:253
~RuntimePin()
Releases the keep-alive; an erased object is destroyed here.
Definition RuntimeRegistry.h:241
RuntimePin & operator=(RuntimePin &&other) noexcept
Move-assigns, releasing any keep-alive this pin already held.
Definition RuntimeRegistry.h:227
T * get() const noexcept
Borrows the pinned object; valid until the pin is released.
Definition RuntimeRegistry.h:250
T * operator->() const noexcept
Pointer-like access to the pinned object.
Definition RuntimeRegistry.h:256
RuntimePin(RuntimePin &&other) noexcept
Moves the keep-alive to a new pin; the source becomes unbound.
Definition RuntimeRegistry.h:219
RuntimePin(const RuntimePin &)=delete
RuntimePin & operator=(const RuntimePin &)=delete
bool isBound() const noexcept
Whether this pin still keeps an object alive.
Definition RuntimeRegistry.h:244
const Ref & reference() const noexcept
The reference this pin was created from.
Definition RuntimeRegistry.h:247
Tag-free slot store behind every RuntimeObjectRegistry<T, Tag>.
Definition RuntimeRegistry.h:67
RuntimeSlotStore & operator=(RuntimeSlotStore &&)=delete
Result< void > erase(std::uint32_t index, std::uint32_t generation, std::uint64_t ownerEpoch)
Destroys the object in a live slot, then advances or retires it.
Definition RuntimeRegistry.cpp:150
void forEachLive(F &&visit)
Visits every live slot with its index, in slot order.
Definition RuntimeRegistry.h:140
void * resolve(std::uint32_t index, std::uint32_t generation, std::uint64_t ownerEpoch) const noexcept
Borrows the live object for these coordinates, or null when stale.
Definition RuntimeRegistry.cpp:108
RuntimeSlotStore(RuntimeSlotStore &&)=delete
bool isStale(std::uint32_t index, std::uint32_t generation, std::uint64_t ownerEpoch) const noexcept
Whether a non-invalid handle can no longer resolve.
Definition RuntimeRegistry.cpp:190
RuntimeSlotStore & operator=(const RuntimeSlotStore &)=delete
Result< void * > pin(std::uint32_t index, std::uint32_t generation, std::uint64_t ownerEpoch)
Keeps one live slot's object alive across erase() and clear().
Definition RuntimeRegistry.cpp:116
Result< RuntimeSlotCoordinates > emplace(void *object)
Stores one object in a fresh or recycled slot.
Definition RuntimeRegistry.cpp:74
void forEachLive(F &&visit) const
Read-only overload: the callback receives const void*.
Definition RuntimeRegistry.h:152
std::uint64_t ownerEpoch() const noexcept
Returns the non-reusable lifetime epoch of this store.
Definition RuntimeRegistry.h:162
void unpin(std::uint32_t index, std::uint64_t ownerEpoch) noexcept
Releases one pin, destroying the object when it was the last one on an erased slot.
Definition RuntimeRegistry.cpp:132
void clear()
Destroys every live object and invalidates every prior handle.
Definition RuntimeRegistry.cpp:199
RuntimeSlotStore(OwnedInstanceDestroy destroy) noexcept
Constructs an empty store that owns no slot.
Definition RuntimeRegistry.h:70
RuntimeSlotStore(const RuntimeSlotStore &)=delete
void(*)(void *) noexcept OwnedInstanceDestroy
Destroys one owned C++ wrapper without knowing its type.
Definition RuntimeRegistry.h:38
void ownedInstanceDestroy(void *pointer) noexcept
Type-erased cleanup used when the VM never took the object.
Definition RuntimeRegistry.h:43
Definition BindingContracts.h:5
std::unique_ptr< T > Owned
C++ owning storage used by an object factory.
Definition RuntimeRegistry.h:33
@ InvalidArgument
Definition Container.h:602
Handle plus owner-lifetime epoch for a non-ECS registry object.
Definition RuntimeBorrow.h:72
Slot coordinates without the domain tag.
Definition RuntimeRegistry.h:48
std::uint32_t generation
Definition RuntimeRegistry.h:50
std::uint32_t index
Definition RuntimeRegistry.h:49