载入中...
搜索中...
未找到
DefinitionRuntime.cpp
浏览该文件的文档.
56RuntimeInstanceCore::RuntimeInstanceCore(InstanceIdentity identity, void* state, CloneFunction clone,
117 eve::DiagnosticCode::InvalidArgument, "definition handle is invalid", "handle", {}, "common.definitions"));
120 eve::DiagnosticCode::StaleHandle, "runtime instance refers to a different definition generation", "handle",
125eve::Result<ReloadOutcome> RuntimeInstanceCore::reload(const DefinitionHandle& next, ReloadPolicy policy,
128 return eve::Result<ReloadOutcome>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
133 eve::DiagnosticCode::Conflict, "definition reload targets a different logical definition", "next.reference",
137 eve::DiagnosticCode::StaleHandle, "definition reload handle is older than the instance generation",
141 identity_.instanceId, identity_.definition, identity_.definitionGeneration, next.generation, policy,
144 return eve::Result<ReloadOutcome>::success(std::move(outcome), eve::Status::success(eve::StatusCode::NoOp));
148 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "active runtime instance rejects definition reload",
151 return eve::Result<ReloadOutcome>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
164 eve::DiagnosticCode::InvalidArgument, "rebuild policy requires a rebuild callback", "rebuild", {},
180 return eve::Result<ReloadOutcome>::success(std::move(outcome), eve::Status::success(eve::StatusCode::Applied));
183 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "definition reload candidate preparation failed", {},
187 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "definition reload candidate preparation failed", {},
192eve::Result<void> RuntimeInstanceCore::restoreExact(const InstanceIdentity& identity, void* state, bool active) {
200 eve::DiagnosticCode::Conflict, "runtime snapshot belongs to a different instance or definition", "identity",
Common identity and hot-reload contract for typed runtime instances.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
Type-erased bookkeeping shared by every RuntimeInstance<State>.
Definition DefinitionRuntime.h:166
std::function< eve::Result< void * >(const void *, const InstanceIdentity &, const DefinitionHandle &)> RebuildFunction
Type-erased rebuild policy callback.
Definition DefinitionRuntime.h:180
void(*)(void *destination, const void *source) AssignFunction
Assigns one payload from another payload of the same state type.
Definition DefinitionRuntime.h:171
eve::Result< ReloadOutcome > reload(const DefinitionHandle &next, ReloadPolicy policy, const void *defaults, const RebuildFunction &rebuild)
Apply a definition replacement with an atomic payload policy.
Definition DefinitionRuntime.cpp:125
eve::Result< void > checkDefinition(const DefinitionHandle &handle) const
Verify that a caller's definition handle is the exact current incarnation.
Definition DefinitionRuntime.cpp:114
void * state() noexcept
Borrow the payload; null only after a move.
Definition DefinitionRuntime.h:205
eve::Result< void > restoreExact(const InstanceIdentity &identity, void *state, bool active)
Swap in an already validated payload of this exact instance.
Definition DefinitionRuntime.cpp:192
RuntimeInstanceCore & operator=(const RuntimeInstanceCore &other)
Copy-assign; the copy is made before any mutation, so a throw leaves *this intact.
Definition DefinitionRuntime.cpp:77
RuntimeInstanceCore(InstanceIdentity identity, void *state, CloneFunction clone, AssignFunction assign, DestroyFunction destroy, bool active) noexcept
Adopt an already-allocated payload.
Definition DefinitionRuntime.cpp:56
void(*)(void *) noexcept DestroyFunction
Destroys one payload; must not throw.
Definition DefinitionRuntime.h:173
const InstanceIdentity & identity() const noexcept
Borrow the complete immutable identity.
Definition DefinitionRuntime.h:203
void *(*)(const void *) CloneFunction
Deep-copies one payload for the copy constructor and copy assignment.
Definition DefinitionRuntime.h:169
Definition DefinitionRuntime.cpp:6
@ RejectWhileActive
Reject the reload while the instance is active; inactive instances keep values.
@ ReapplyDefaults
Replace the typed state with defaults produced from the new definition.
@ RebuildInstance
Let the consumer atomically construct a new state from the new definition.
ReloadDisposition
Observable result of a successful or no-op definition reload.
Definition DefinitionRuntime.h:132
@ DefaultsReapplied
@ InvalidArgument
@ Failed
@ StaleHandle
@ Conflict
@ NoOp
@ Applied
A generation-qualified reference to one definition incarnation.
Definition DefinitionRuntime.h:69
Canonical identity carried by every typed runtime instance.
Definition DefinitionRuntime.h:87
eve::DefinitionRef definition
Definition DefinitionRuntime.h:89
eve::PersistentId instanceId
Definition DefinitionRuntime.h:88
bool isValid() const noexcept
Whether this identity has all required non-zero fields.
Definition DefinitionRuntime.h:123
DefinitionHandle definitionHandle() const noexcept
Convert the logical reference and generation into a checked handle.
Definition DefinitionRuntime.h:118
eve::Generation definitionGeneration
Definition DefinitionRuntime.h:90
Identity transition emitted by a typed runtime reload operation.
Definition DefinitionRuntime.h:140