alloc_observe.install
Internal implementation documentation
Defined in alloc_observe.
Installs a borrowed sink and context as the active observation target, returning an active session handle.
Source
Source: lib/alloc/observe/src/protocol.zig:490
zig
/// Installs a borrowed sink and context as the active observation target,/// returning an active session handle. If an enabled sink is already installed,/// the function returns AlreadyInstalled. In disabled builds, installation/// succeeds inertly. The caller must guarantee that sink storage and context/// pointers remain valid and stationary, because registered producers on other/// threads may deliver callbacks before install returns. The function must be/// called outside existing callbacks and suppression scopes. Callers must/// serialize session lifecycles externally, ensuring that prior session/// teardown completes fully before a new session is installed.pub fn install(sink: *const Sink) error{AlreadyInstalled}!Session { if (comptime !enabled) { return .{}; } std.debug.assert(callback_depth == 0); lockProducerRegistry(); defer producer_registry_lock.unlock(); const address = @intFromPtr(sink); std.debug.assert(address != 0); const producer_id_floor = next_producer_id.load(.acquire); if (active_sink.cmpxchgStrong( 0, address, .acq_rel, .acquire, ) != null) { return error.AlreadyInstalled; } return .{ .sink = sink, .active = true, .producer_id_floor = producer_id_floor, };}Source: lib/alloc/observe/src/root.zig:494
zig
/// Installs a borrowed sink and context as the active observation target,/// returning an active session handle. If an enabled sink is already installed,/// the function returns AlreadyInstalled. In disabled builds, installation/// succeeds inertly. The caller must guarantee that sink storage and context/// pointers remain valid and stationary, because registered producers on other/// threads may deliver callbacks before install returns. The function must be/// called outside existing callbacks and suppression scopes. Callers must/// serialize session lifecycles externally, ensuring that prior session/// teardown completes fully before a new session is installed.pub const install = protocol.install;Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |