Declared Resource Manager#

class DeclaredResourceAllocator#

Allocation seam for Initialization/healthy Deinitialization and local fault injection. On failure, output still identifies any acquired resource; release failure retains ownership. Memory has at least fundamental alignment. The allocator outlives the resource manager.

Public Functions

virtual ~DeclaredResourceAllocator() = default#
virtual SafetyStatus allocate(
RuntimeMemoryRequest const &request,
void *&output
) noexcept = 0#
virtual SafetyStatus release(RuntimeMemoryView memory) noexcept = 0#
virtual SafetyStatus createStream(cudaStream_t &output) noexcept = 0#
virtual SafetyStatus destroyStream(cudaStream_t stream) noexcept = 0#
virtual SafetyStatus createEvent(cudaEvent_t &output) noexcept = 0#
virtual SafetyStatus destroyEvent(cudaEvent_t event) noexcept = 0#
class DeclaredResourceManager#

Owned by SafetyRuntime; access and lifecycle calls are externally serialized. Destroy capabilities/model-local objects before deinitialize(). Destruction performs no SDK calls.

Public Functions

explicit DeclaredResourceManager(
LifecycleState &lifecycleState
) noexcept#
DeclaredResourceManager(
LifecycleState &lifecycleState,
DeclaredResourceAllocator &allocator
) noexcept#
~DeclaredResourceManager() noexcept#
DeclaredResourceManager(DeclaredResourceManager const&) = delete#
DeclaredResourceManager &operator=(
DeclaredResourceManager const&
) = delete#
SafetyStatus prepareResources(
std::vector<ResourceDeclaration> const &declarations
) noexcept#

Validate every declaration, then allocate owned resources. Views become available only on success.

SafetyStatus resolveBorrowedResources(
ResourceOwnerId owner,
BorrowedResourceResolver const &resolver
) noexcept#

Resolve one owner’s borrows atomically. Resolve factory inputs before constructing model-local objects, then resolve capabilities borrowing those objects. All owners must be resolved before Operational.

SafetyStatus resourcesFor(
ResourceOwnerId owner,
PreparedResources &output
) const noexcept#
SafetyStatus memory(
ResourceOwnerId owner,
RuntimeResourceKey key,
RuntimeMemoryView &output
) const noexcept#

Typed lookups validate the owner, preparation and lifecycle before exposing a borrowed view.

SafetyStatus tensor(
ResourceOwnerId owner,
RuntimeResourceKey key,
RuntimeTensorView const *&output
) const noexcept#
SafetyStatus stream(
ResourceOwnerId owner,
RuntimeResourceKey key,
cudaStream_t &output
) const noexcept#
SafetyStatus event(
ResourceOwnerId owner,
RuntimeResourceKey key,
cudaEvent_t &output
) const noexcept#
SafetyStatus modelLocalData(
ResourceOwnerId owner,
RuntimeResourceKey key,
SafetyModelLocalData *&output
) const noexcept#
SafetyStatus containerStorage(
ResourceOwnerId owner,
SafetyContainerStorage *&output
) const noexcept#
SafetyStatus validateInitialization(
ResourceOwnerId owner
) const noexcept#

Factory/capability setup requires prepared resources during Initialization.

SafetyStatus validatePrepared() const noexcept#

Check all borrows before SafetyRuntime publishes Operational readiness.

SafetyStatus status() const noexcept#
inline bool hasResources() const noexcept#
SafetyStatus deinitialize() noexcept#

SafetyRuntime closes execution before caller-owned objects and declared storage are released.

void abandonAfterFatal(SafetyStatus status) noexcept#

Latch an external fatal failure before any attempted teardown; retain resources for containment.