Skip to documentation
SLOP

tiny.coz.Registry

Reference tiny.coz Registry

Defined in registry.

API (9)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callsregistryRegistry
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/coz/src/registry.zig:6

zig
pub const Registry = struct {    mutex: std.atomic.Mutex = .unlocked,    throughput_points: std.StringHashMapUnmanaged(*progress_point.ThroughputPoint) = .empty,    latency_points: std.StringHashMapUnmanaged(*progress_point.LatencyPoint) = .empty,    pub fn deinit(self: *Registry, allocator: std.mem.Allocator) void {        lockMutex(&self.mutex);        defer self.mutex.unlock();        var throughput_iter = self.throughput_points.iterator();        while (throughput_iter.next()) |entry| {            allocator.free(entry.key_ptr.*);            allocator.destroy(entry.value_ptr.*);        }        self.throughput_points.deinit(allocator);        var latency_iter = self.latency_points.iterator();        while (latency_iter.next()) |entry| {            allocator.free(entry.key_ptr.*);            allocator.destroy(entry.value_ptr.*);        }        self.latency_points.deinit(allocator);        self.throughput_points = .empty;        self.latency_points = .empty;    }    pub fn getThroughputPoint(        self: *Registry,        allocator: std.mem.Allocator,        name: []const u8,    ) !*progress_point.ThroughputPoint {        lockMutex(&self.mutex);        defer self.mutex.unlock();        if (self.throughput_points.get(name)) |point| return point;        const owned_name = try allocator.dupe(u8, name);        errdefer allocator.free(owned_name);        const point = try allocator.create(progress_point.ThroughputPoint);        errdefer allocator.destroy(point);        point.* = progress_point.ThroughputPoint.init(owned_name);        try self.throughput_points.put(allocator, owned_name, point);        return point;    }    pub fn getLatencyPoint(        self: *Registry,        allocator: std.mem.Allocator,        name: []const u8,    ) !*progress_point.LatencyPoint {        lockMutex(&self.mutex);        defer self.mutex.unlock();        if (self.latency_points.get(name)) |point| return point;        const owned_name = try allocator.dupe(u8, name);        errdefer allocator.free(owned_name);        const point = try allocator.create(progress_point.LatencyPoint);        errdefer allocator.destroy(point);        point.* = progress_point.LatencyPoint.init(owned_name);        try self.latency_points.put(allocator, owned_name, point);        return point;    }    pub fn getCounter(        self: *Registry,        allocator: std.mem.Allocator,        kind: abi.CounterKind,        name: []const u8,    ) !*abi.Counter {        return switch (kind) {            .throughput => (try self.getThroughputPoint(allocator, name)).counterStruct(),            .begin => (try self.getLatencyPoint(allocator, name)).beginCounterStruct(),            .end => (try self.getLatencyPoint(allocator, name)).endCounterStruct(),        };    }    pub fn saveThroughputSnapshots(        self: *Registry,        allocator: std.mem.Allocator,    ) ![]progress_point.ThroughputSnapshot {        lockMutex(&self.mutex);        defer self.mutex.unlock();        var snapshots: std.ArrayListUnmanaged(progress_point.ThroughputSnapshot) = .empty;        errdefer snapshots.deinit(allocator);        var iter = self.throughput_points.valueIterator();        while (iter.next()) |point| {            try snapshots.append(allocator, point.*.save());        }        return snapshots.toOwnedSlice(allocator);    }    pub fn saveLatencySnapshots(        self: *Registry,        allocator: std.mem.Allocator,    ) ![]progress_point.LatencySnapshot {        lockMutex(&self.mutex);        defer self.mutex.unlock();        var snapshots: std.ArrayListUnmanaged(progress_point.LatencySnapshot) = .empty;        errdefer snapshots.deinit(allocator);        var iter = self.latency_points.valueIterator();        while (iter.next()) |point| {            try snapshots.append(allocator, point.*.save());        }        return snapshots.toOwnedSlice(allocator);    }};

Source: lib/coz/src/root.zig:62

zig
pub const Registry = registry.Registry;
Called byCallstest sourcelib.coz.src.registrytest: registry keeps throughput and l...test sourcelib.coz.src.registrytest: registry returns a stable throu...test sourcelib.coz.src.registrytest: registry returns stable latency...test sourcelib.coz.src.registrytest: registry snapshots record delta...private sourcelib.coz.src.registrylockMutexRegistrydeinit
Static calls · unresolved targets: 0 · external targets: 7.
Called byCallstest sourcelib.coz.src.registrytest: registry returns a stable throu...test sourcelib.coz.src.registrytest: registry returns stable latency...RegistrygetLatencyPointRegistrygetThroughputPointRegistrygetCounter
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsRegistrygetCountertest sourcelib.coz.src.registrytest: registry keeps throughput and l...test sourcelib.coz.src.registrytest: registry returns stable latency...test sourcelib.coz.src.registrytest: registry snapshots record delta...private sourcelib.coz.src.registrylockMutexRegistrygetLatencyPoint
Static calls · unresolved targets: 2 · external targets: 6.
Called byCallsRegistrygetCountertest sourcelib.coz.src.registrytest: registry keeps throughput and l...test sourcelib.coz.src.registrytest: registry returns a stable throu...test sourcelib.coz.src.registrytest: registry snapshots record delta...private sourcelib.coz.src.registrylockMutexRegistrygetThroughputPoint
Static calls · unresolved targets: 2 · external targets: 6.
Called byCallstest sourcelib.coz.src.registrytest: registry snapshots record delta...private sourcelib.coz.src.registrylockMutexRegistrysaveLatencySnapshots
Static calls · unresolved targets: 1 · external targets: 5.
Called byCallstest sourcelib.coz.src.registrytest: registry snapshots record delta...private sourcelib.coz.src.registrylockMutexRegistrysaveThroughputSnapshots
Static calls · unresolved targets: 1 · external targets: 5.

Audit

Definitions7
Public names14
Members3
Version26.7.0
Revisiondaab053ee433