载入中...
搜索中...
未找到
eve::definition::RuntimeInstanceCore类 参考

Type-erased bookkeeping shared by every RuntimeInstance<State>. 更多...

#include <DefinitionRuntime.h>

Public 类型

using CloneFunction = void *(*)(const void *)
 Deep-copies one payload for the copy constructor and copy assignment.
 
using AssignFunction = void(*)(void *destination, const void *source)
 Assigns one payload from another payload of the same state type.
 
using DestroyFunction = void(*)(void *) noexcept
 Destroys one payload; must not throw.
 
using RebuildFunction = std::function< eve::Result< void * >(const void *, const InstanceIdentity &, const DefinitionHandle &)>
 Type-erased rebuild policy callback.
 

Public 成员函数

 RuntimeInstanceCore (InstanceIdentity identity, void *state, CloneFunction clone, AssignFunction assign, DestroyFunction destroy, bool active) noexcept
 Adopt an already-allocated payload.
 
 ~RuntimeInstanceCore ()
 Destroy the adopted payload.
 
 RuntimeInstanceCore (const RuntimeInstanceCore &other)
 Deep-copy the payload and the bookkeeping.
 
RuntimeInstanceCore & operator= (const RuntimeInstanceCore &other)
 Copy-assign; the copy is made before any mutation, so a throw leaves *this intact.
 
 RuntimeInstanceCore (RuntimeInstanceCore &&other) noexcept
 Move the payload and the bookkeeping.
 
RuntimeInstanceCore & operator= (RuntimeInstanceCore &&other) noexcept
 Move-assign, destroying the current payload.
 
const InstanceIdentity & identity () const noexcept
 Borrow the complete immutable identity.
 
void * state () noexcept
 Borrow the payload; null only after a move.
 
const void * state () const noexcept
 Borrow the payload; null only after a move.
 
bool isActive () const noexcept
 Whether the instance participates in active simulation.
 
void setActive (bool active) noexcept
 Set active state; this does not reload or rebuild the instance.
 
eve::Result< void > checkDefinition (const DefinitionHandle &handle) const
 Verify that a caller's definition handle is the exact current incarnation.
 
eve::Result< ReloadOutcome > reload (const DefinitionHandle &next, ReloadPolicy policy, const void *defaults, const RebuildFunction &rebuild)
 Apply a definition replacement with an atomic payload policy.
 
eve::Result< void > restoreExact (const InstanceIdentity &identity, void *state, bool active)
 Swap in an already validated payload of this exact instance.
 

详细描述

Type-erased bookkeeping shared by every RuntimeInstance<State>.

Identity validation, the active flag, the reload policy machine and the error construction are identical for every domain state, so they live in one non-template core compiled once in DefinitionRuntime.cpp instead of being instantiated once per state type.

The payload stays strongly typed at the public API: this core only carries it as an owning pointer plus the per-state clone/assign/destroy operations. It is never turned into a dynamic field map.

Thread affinity matches RuntimeInstance: the owning domain thread only.

在文件 DefinitionRuntime.h 第 166 行定义.

成员类型定义说明

◆ AssignFunction

using eve::definition::RuntimeInstanceCore::AssignFunction = void (*)(void* destination, const void* source)

Assigns one payload from another payload of the same state type.

在文件 DefinitionRuntime.h 第 171 行定义.

◆ CloneFunction

Deep-copies one payload for the copy constructor and copy assignment.

在文件 DefinitionRuntime.h 第 169 行定义.

◆ DestroyFunction

Destroys one payload; must not throw.

在文件 DefinitionRuntime.h 第 173 行定义.

◆ RebuildFunction

using eve::definition::RuntimeInstanceCore::RebuildFunction = std::function<eve::Result<void*>(const void*, const InstanceIdentity&, const DefinitionHandle&)>

Type-erased rebuild policy callback.

返回
A newly allocated payload whose ownership transfers to the core, or a failure that leaves the core unchanged.

在文件 DefinitionRuntime.h 第 179 行定义.

构造及析构函数说明

◆ RuntimeInstanceCore() [1/3]

eve::definition::RuntimeInstanceCore::RuntimeInstanceCore ( InstanceIdentity  identity,
void *  state,
CloneFunction  clone,
AssignFunction  assign,
DestroyFunction  destroy,
bool  active 
)
noexcept

Adopt an already-allocated payload.

参数
statePayload this core now owns and destroys with destroy. @ownership Takes ownership of state; all four function pointers must stay valid for the lifetime of the core.

在文件 DefinitionRuntime.cpp 第 56 行定义.

◆ ~RuntimeInstanceCore()

eve::definition::RuntimeInstanceCore::~RuntimeInstanceCore ( )

Destroy the adopted payload.

在文件 DefinitionRuntime.cpp 第 65 行定义.

◆ RuntimeInstanceCore() [2/3]

eve::definition::RuntimeInstanceCore::RuntimeInstanceCore ( const RuntimeInstanceCore &  other)

Deep-copy the payload and the bookkeeping.

在文件 DefinitionRuntime.cpp 第 69 行定义.

◆ RuntimeInstanceCore() [3/3]

eve::definition::RuntimeInstanceCore::RuntimeInstanceCore ( RuntimeInstanceCore &&  other)
noexcept

Move the payload and the bookkeeping.

在文件 DefinitionRuntime.cpp 第 91 行定义.

成员函数说明

◆ checkDefinition()

eve::Result< void > eve::definition::RuntimeInstanceCore::checkDefinition ( const DefinitionHandle &  handle) const

Verify that a caller's definition handle is the exact current incarnation.

返回
Success for an exact match, or StaleHandle/invalid-argument otherwise.

在文件 DefinitionRuntime.cpp 第 114 行定义.

引用了 eve::definition::InstanceIdentity::definitionHandle(), eve::Diagnostic::error(), eve::Result< T >::failure(), handle, eve::InvalidArgument, eve::StaleHandle , 以及 eve::Result< T >::success().

被这些函数引用 eve::definition::RuntimeInstance< State >::checkDefinition().

◆ identity()

const InstanceIdentity & eve::definition::RuntimeInstanceCore::identity ( ) const
inlinenoexcept

Borrow the complete immutable identity.

在文件 DefinitionRuntime.h 第 203 行定义.

被这些函数引用 eve::definition::RuntimeInstance< State >::identity() , 以及 restoreExact().

◆ isActive()

bool eve::definition::RuntimeInstanceCore::isActive ( ) const
inlinenoexcept

Whether the instance participates in active simulation.

在文件 DefinitionRuntime.h 第 209 行定义.

被这些函数引用 eve::definition::RuntimeInstance< State >::isActive().

◆ operator=() [1/2]

RuntimeInstanceCore & eve::definition::RuntimeInstanceCore::operator= ( const RuntimeInstanceCore &  other)

Copy-assign; the copy is made before any mutation, so a throw leaves *this intact.

在文件 DefinitionRuntime.cpp 第 77 行定义.

◆ operator=() [2/2]

RuntimeInstanceCore & eve::definition::RuntimeInstanceCore::operator= ( RuntimeInstanceCore &&  other)
noexcept

Move-assign, destroying the current payload.

在文件 DefinitionRuntime.cpp 第 101 行定义.

◆ reload()

eve::Result< ReloadOutcome > eve::definition::RuntimeInstanceCore::reload ( const DefinitionHandle &  next,
ReloadPolicy  policy,
const void *  defaults,
const RebuildFunction &  rebuild 
)

Apply a definition replacement with an atomic payload policy.

参数
nextExact current handle returned by the DefinitionRegistry.
policyPolicy to execute for this instance.
defaultsPayload used only by ReapplyDefaults; required by that policy.
rebuildCallback used only by RebuildInstance.
返回
Reload transition, or a failure leaving payload and identity intact.
备注
RejectWhileActive rejects active instances. When inactive it intentionally keeps values and only advances the generation.

在文件 DefinitionRuntime.cpp 第 125 行定义.

引用了 eve::Applied, eve::Conflict, eve::definition::DefaultsReapplied, eve::definition::InstanceIdentity::definition, eve::definition::InstanceIdentity::definitionGeneration, eve::Diagnostic::error(), eve::Failed, eve::Result< T >::failure(), eve::definition::InstanceIdentity::instanceId, eve::InvalidArgument, eve::definition::Kept, eve::NoOp, eve::definition::ReapplyDefaults, eve::definition::RebuildInstance, eve::definition::Rebuilt, eve::definition::RejectWhileActive, eve::StaleHandle, eve::Status::success(), eve::Result< T >::success() , 以及 eve::definition::Unchanged.

◆ restoreExact()

eve::Result< void > eve::definition::RuntimeInstanceCore::restoreExact ( const InstanceIdentity &  identity,
void *  state,
bool  active 
)

Swap in an already validated payload of this exact instance.

参数
stateNewly allocated payload; the core adopts it and destroys it when validation fails.
返回
Success, or Conflict/StaleHandle when the snapshot belongs to a different instance or definition incarnation.

在文件 DefinitionRuntime.cpp 第 192 行定义.

引用了 active, eve::Conflict, eve::definition::InstanceIdentity::definition, eve::definition::InstanceIdentity::definitionGeneration, eve::Diagnostic::error(), eve::Result< T >::failure(), identity(), eve::definition::InstanceIdentity::instanceId, eve::InvalidArgument, eve::definition::InstanceIdentity::isValid(), eve::StaleHandle, state() , 以及 eve::Result< T >::success().

被这些函数引用 eve::definition::RuntimeInstance< State >::restoreExact().

◆ setActive()

void eve::definition::RuntimeInstanceCore::setActive ( bool  active)
inlinenoexcept

Set active state; this does not reload or rebuild the instance.

在文件 DefinitionRuntime.h 第 211 行定义.

引用了 active.

被这些函数引用 eve::definition::RuntimeInstance< State >::setActive().

◆ state() [1/2]

const void * eve::definition::RuntimeInstanceCore::state ( ) const
inlinenoexcept

Borrow the payload; null only after a move.

在文件 DefinitionRuntime.h 第 207 行定义.

◆ state() [2/2]

void * eve::definition::RuntimeInstanceCore::state ( )
inlinenoexcept

Borrow the payload; null only after a move.

在文件 DefinitionRuntime.h 第 205 行定义.

被这些函数引用 restoreExact(), eve::definition::RuntimeInstance< State >::state() , 以及 eve::definition::RuntimeInstance< State >::state().


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