Tag-free slot store behind every RuntimeObjectRegistry<T, Tag>. 更多...
#include <RuntimeRegistry.h>
Public 成员函数 | |
| RuntimeSlotStore (OwnedInstanceDestroy destroy) noexcept | |
| Constructs an empty store that owns no slot. | |
| RuntimeSlotStore (const RuntimeSlotStore &)=delete | |
| RuntimeSlotStore & | operator= (const RuntimeSlotStore &)=delete |
| RuntimeSlotStore (RuntimeSlotStore &&)=delete | |
| RuntimeSlotStore & | operator= (RuntimeSlotStore &&)=delete |
| ~RuntimeSlotStore () | |
| Releases RuntimeSlotStore resources. | |
| Result< RuntimeSlotCoordinates > | emplace (void *object) |
| Stores one object in a fresh or recycled slot. | |
| 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. | |
| 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. | |
| 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. | |
| 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(). | |
| 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. | |
| void | clear () |
| Destroys every live object and invalidates every prior handle. | |
| template<class F > | |
| void | forEachLive (F &&visit) |
| Visits every live slot with its index, in slot order. | |
| template<class F > | |
| void | forEachLive (F &&visit) const |
Read-only overload: the callback receives const void*. | |
| std::uint64_t | ownerEpoch () const noexcept |
| Returns the non-reusable lifetime epoch of this store. | |
详细描述
Tag-free slot store behind every RuntimeObjectRegistry<T, Tag>.
Holds raw pointers and one destroy hook, so it never sees T or Tag. The bookkeeping it performs – free-list reuse, generation bumping, slot retirement at generation exhaustion, owner-epoch staleness and the release rollback – is identical for every registry and is emitted once here instead of once per (T, Tag) pair.
- 备注
- Ownership rule for emplace(): the store takes the object only on success. A failed emplace leaves the object with the caller, which still owns it. @thread Owner-thread-affine; no synchronization is provided.
在文件 RuntimeRegistry.h 第 134 行定义.
构造及析构函数说明
◆ RuntimeSlotStore() [1/3]
|
inlineexplicitnoexcept |
Constructs an empty store that owns no slot.
在文件 RuntimeRegistry.h 第 137 行定义.
◆ RuntimeSlotStore() [2/3]
|
delete |
◆ RuntimeSlotStore() [3/3]
|
delete |
◆ ~RuntimeSlotStore()
| eve::script::detail::RuntimeSlotStore::~RuntimeSlotStore | ( | ) |
Releases RuntimeSlotStore resources.
在文件 RuntimeRegistry.cpp 第 37 行定义.
成员函数说明
◆ clear()
| void eve::script::detail::RuntimeSlotStore::clear | ( | ) |
Destroys every live object and invalidates every prior handle.
在文件 RuntimeRegistry.cpp 第 199 行定义.
引用了 index.
◆ emplace()
| Result< RuntimeSlotCoordinates > eve::script::detail::RuntimeSlotStore::emplace | ( | void * | object | ) |
Stores one object in a fresh or recycled slot.
- 参数
-
object Non-null object whose destruction becomes store-owned.
- 返回
- The slot coordinates, or a structured failure. @ownership On success the store owns
objectand destroys it through its destroy hook; on failure the caller keeps ownership.
在文件 RuntimeRegistry.cpp 第 74 行定义.
引用了 error, eve::Failed, eve::script::detail::RuntimeSlotCoordinates::generation, index, eve::InvariantViolation, object , 以及 eve::Result< T >::success().
◆ erase()
| Result< void > eve::script::detail::RuntimeSlotStore::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.
在文件 RuntimeRegistry.cpp 第 150 行定义.
引用了 eve::Applied, error, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), generation, index, eve::InvalidArgument, ownerEpoch(), eve::Status::success() , 以及 eve::Result< T >::success().
◆ forEachLive() [1/2]
|
inline |
Visits every live slot with its index, in slot order.
The store holds untyped pointers, so it reports the index and the raw object; the typed registry narrows that pair into (index, T&). Retired and free slots are skipped, so the callback only ever sees live objects.
- 参数
-
visit Callable taking (std::uint32_t index, void* object). @thread Owner thread only; the callback runs under no lock and must not re-enter the store.
For each live.
Visit.
在文件 RuntimeRegistry.h 第 207 行定义.
引用了 index.
◆ forEachLive() [2/2]
|
inline |
Read-only overload: the callback receives const void*.
For each live.
Visit.
在文件 RuntimeRegistry.h 第 219 行定义.
引用了 index.
◆ isStale()
|
noexcept |
Whether a non-invalid handle can no longer resolve.
在文件 RuntimeRegistry.cpp 第 190 行定义.
引用了 generation , 以及 index.
◆ operator=() [1/2]
|
delete |
◆ operator=() [2/2]
|
delete |
◆ ownerEpoch()
|
inlinenoexcept |
Returns the non-reusable lifetime epoch of this store.
在文件 RuntimeRegistry.h 第 229 行定义.
◆ pin()
| Result< void * > eve::script::detail::RuntimeSlotStore::pin | ( | std::uint32_t | index, |
| std::uint32_t | generation, | ||
| std::uint64_t | ownerEpoch | ||
| ) |
Keeps one live slot's object alive across erase() and clear().
- 参数
-
index Slot index taken from the reference. generation Slot generation taken from the reference. ownerEpoch Owner epoch taken from the reference.
- 返回
- The live object, or a stale-handle failure. @ownership The object stays store-owned; the pin only postpones destruction.
- 备注
- Every successful pin must be matched by exactly one unpin().
在文件 RuntimeRegistry.cpp 第 116 行定义.
引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), generation, index, eve::InvalidArgument, eve::InvariantViolation, ownerEpoch() , 以及 eve::Result< T >::success().
◆ resolve()
|
noexcept |
Borrows the live object for these coordinates, or null when stale.
在文件 RuntimeRegistry.cpp 第 108 行定义.
引用了 generation , 以及 index.
◆ unpin()
|
noexcept |
Releases one pin, destroying the object when it was the last one on an erased slot.
- 参数
-
index Slot index taken from the reference. ownerEpoch Owner epoch taken from the reference.
- 备注
- Safe to call on a stale slot or an already released pin: unpinning more often than pinning is a no-op, never a destruction.
在文件 RuntimeRegistry.cpp 第 132 行定义.
引用了 index.
该类的文档由以下文件生成:
- src/engine/common/RuntimeRegistry.h
- src/engine/common/RuntimeRegistry.cpp