Skip to content
class

OpRegistry

OpRegistry

Thread-safe global op registry.

All methods are static; the underlying map and its lock live in a function-local static inside OpRegistry.cpp. Schemas are stored by non-owning pointer — the caller (typically a constexpr static in an op's translation unit) must guarantee that the pointee outlives the registry.

Notes

The map keys are std::string_view references into each schema's name field. Because schemas are required to live for the process lifetime, the keys are stable for the same duration — no string copying or hashing of string contents per lookup is needed.

Static methods

4
static

all

→std::vector<const OpSchema*>
int all()

Returns a snapshot of every registered schema.

Acquires a shared read lock. The snapshot is a freshly allocated vector; the schemas it points to remain valid for the process lifetime.

Returns

std::vector<const OpSchema*>

All currently registered schemas, ordered alphabetically by name (the backing container is a std::map).

Notes

Intended for diagnostics, profiler dumps, and Python introspection — not for the hot dispatch path, which should use lookup.

static

lookup

→const OpSchema*
const OpSchema * lookup(int name)

Looks up a registered schema by canonical op name.

Acquires a shared read lock. Multiple threads may call concurrently.

Parameters

namestd::string_view
Canonical op name as registered (case-sensitive).

Returns

const OpSchema*

Pointer to the registered schema, or nullptr when no op of that name exists. The returned pointer is stable for the lifetime of the process.

static

register_op

void register_op(const OpSchema & schema)

Registers a schema under schema.name.

Acquires an exclusive write lock. If an op with the same name was already registered the entry is silently overwritten — this is intentional, to let tests inject mocked schemas without going through a deregister API. Production code registers each schema exactly once at static-init time.

Parameters

schemaconst OpSchema&
A schema whose lifetime exceeds the registry's (constexpr static is the canonical case). Only the pointer is stored.

Notes

schema.name is captured as a std::string_view; do not pass schemas whose name is backed by a temporary std::string.

static

size

→std::size_t
int size()

Returns the number of registered ops.

Acquires a shared read lock.

Returns

std::size_t

Current size of the registry.