Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
Loading...
Searching...
No Matches
donner::gpu::Handle< Tag > Class Template Reference

Move-only handle to a device resource. More...

#include "donner/gpu/Handles.h"

Public Member Functions

 Handle ()=default
 Constructs a null handle.
 ~Handle ()=default
 Destructor. Intentionally does not free the resource (see file comment).
 Handle (const Handle &)=delete
Handleoperator= (const Handle &)=delete
 Handle (Handle &&other) noexcept
 Move constructor; other becomes null.
Handleoperator= (Handle &&other) noexcept
 Move assignment; other becomes null.
bool isValid () const
 Returns true if this handle is non-null. The device generation check is authoritative for whether the resource is still alive.
uint32_t slotIndex () const
 Resource table slot index, for backend use.
uint32_t generation () const
 Slot generation at creation time, for backend use. Zero for null handles.
uint64_t deviceId () const
 Identity of the owning device (see Device::deviceId()), for backend use. Zero for null handles.

Static Public Member Functions

static Handle CreateForBackend (uint32_t slotIndex, uint32_t generation, uint64_t deviceId)
 Mints a live handle; called by device backends only.

Friends

bool operator== (const Handle &handle, std::nullptr_t)
 Compares against null: true if the handle is null.

Detailed Description

template<typename Tag>
class donner::gpu::Handle< Tag >

Move-only handle to a device resource.

A handle carries a (slot, generation) pair plus the identity of the owning device. The device validates all three on every use, so a null handle, a stale handle (the resource was destroyed, possibly with its slot reused), or a handle from a different device fails closed with GpuErrorType::InvalidHandle / GpuErrorType::DeviceMismatch instead of reaching a backend. Validation runs in release builds too.

A default-constructed or moved-from handle is null (isValid() returns false).

Template Parameters
TagTag type identifying the resource type; provides Tag::kName for diagnostics.

Constructor & Destructor Documentation

◆ Handle()

template<typename Tag>
donner::gpu::Handle< Tag >::Handle ( Handle< Tag > && other)
inlinenoexcept

Move constructor; other becomes null.

Parameters
otherHandle to move from.

Member Function Documentation

◆ CreateForBackend()

template<typename Tag>
Handle donner::gpu::Handle< Tag >::CreateForBackend ( uint32_t slotIndex,
uint32_t generation,
uint64_t deviceId )
inlinestatic

Mints a live handle; called by device backends only.

Parameters
slotIndexResource table slot index.
generationSlot generation at creation time; must be nonzero.
deviceIdIdentity of the owning device.

◆ operator=()

template<typename Tag>
Handle & donner::gpu::Handle< Tag >::operator= ( Handle< Tag > && other)
inlinenoexcept

Move assignment; other becomes null.

Parameters
otherHandle to move from.

◆ operator==

template<typename Tag>
bool operator== ( const Handle< Tag > & handle,
std::nullptr_t  )
friend

Compares against null: true if the handle is null.

Parameters
handleHandle to test.

The documentation for this class was generated from the following file: