载入中...
搜索中...
未找到
eve::script::detail::RuntimeSlotStore类 参考

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]

eve::script::detail::RuntimeSlotStore::RuntimeSlotStore ( OwnedInstanceDestroy  destroy)
inlineexplicitnoexcept

Constructs an empty store that owns no slot.

在文件 RuntimeRegistry.h 第 137 行定义.

◆ RuntimeSlotStore() [2/3]

eve::script::detail::RuntimeSlotStore::RuntimeSlotStore ( const RuntimeSlotStore &  )
delete

◆ RuntimeSlotStore() [3/3]

eve::script::detail::RuntimeSlotStore::RuntimeSlotStore ( RuntimeSlotStore &&  )
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.

参数
objectNon-null object whose destruction becomes store-owned.
返回
The slot coordinates, or a structured failure. @ownership On success the store owns object and 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]

template<class F >
void eve::script::detail::RuntimeSlotStore::forEachLive ( F &&  visit)
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.

参数
visitCallable 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]

template<class F >
void eve::script::detail::RuntimeSlotStore::forEachLive ( F &&  visit) const
inline

Read-only overload: the callback receives const void*.

For each live.

Visit.

在文件 RuntimeRegistry.h 第 219 行定义.

引用了 index.

◆ isStale()

bool eve::script::detail::RuntimeSlotStore::isStale ( std::uint32_t  index,
std::uint32_t  generation,
std::uint64_t  ownerEpoch 
) const
noexcept

Whether a non-invalid handle can no longer resolve.

在文件 RuntimeRegistry.cpp 第 190 行定义.

引用了 generation , 以及 index.

◆ operator=() [1/2]

RuntimeSlotStore & eve::script::detail::RuntimeSlotStore::operator= ( const RuntimeSlotStore &  )
delete

◆ operator=() [2/2]

RuntimeSlotStore & eve::script::detail::RuntimeSlotStore::operator= ( RuntimeSlotStore &&  )
delete

◆ ownerEpoch()

std::uint64_t eve::script::detail::RuntimeSlotStore::ownerEpoch ( ) const
inlinenoexcept

Returns the non-reusable lifetime epoch of this store.

在文件 RuntimeRegistry.h 第 229 行定义.

被这些函数引用 erase() , 以及 pin().

◆ 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().

参数
indexSlot index taken from the reference.
generationSlot generation taken from the reference.
ownerEpochOwner 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()

void * eve::script::detail::RuntimeSlotStore::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.

在文件 RuntimeRegistry.cpp 第 108 行定义.

引用了 generation , 以及 index.

◆ unpin()

void eve::script::detail::RuntimeSlotStore::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.

参数
indexSlot index taken from the reference.
ownerEpochOwner 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.


该类的文档由以下文件生成: