alloc_observe.Session
Internal implementation documentation
Defined in alloc_observe.
Represents an installed observation interval, managing session duration while borrowing caller-owned sink and context storage.
API (5)
Actions
Public operations.
deinit: Terminates an active session by unregistering the sink and spinning until the shared count of active spans and contexts drains to zero.producerIdFloor: Reports the next producer identifier captured during session installation under the registry lock, or zero when observation is disabled.
Fields and members
Public fields and members.
Source
Source: lib/alloc/observe/src/protocol.zig:420
zig
/// Represents an installed observation interval, managing session duration/// while borrowing caller-owned sink and context storage. Callers must ensure/// sink and context storage remain allocated at stable memory addresses/// throughout the session. The session must be explicitly terminated by calling/// deinit exactly once, as no automatic teardown is performed on drop. In/// disabled builds, the session is inert. Callers must serialize session/// lifecycle transitions externally, because the protocol does not support/// overlapping the shutdown of an old session with the installation of a new/// one.pub const Session = struct { sink: if (enabled) ?*const Sink else void = if (enabled) null else {}, active: if (enabled) bool else void = if (enabled) false else {}, producer_id_floor: if (enabled) u64 else void = if (enabled) 0 else {}, /// Terminates an active session by unregistering the sink and spinning /// until the shared count of active spans and contexts drains to zero. The /// spin loop contains no timeout or cancellation path, requiring all /// concurrent operations to finish. Callers must invoke deinit outside /// callbacks and outside active suppression scopes (which trigger /// assertions if violated), and must ensure no outstanding spans or /// contexts remain open on the calling thread, or shutdown will spin /// indefinitely. Callers must also avoid holding locks required by /// in-flight callbacks. `Sink` memory and callback context pointers must /// remain valid and stable until this function returns. An enabled session /// must be deinitialized exactly once. In disabled builds, this call is an /// inert no-op. pub fn deinit(self: *Session) void { if (comptime !enabled) return; std.debug.assert(callback_depth == 0); std.debug.assert(self.active); const sink = self.sink.?; const address = @intFromPtr(sink); const previous = active_sink.cmpxchgStrong( address, 0, .acq_rel, .acquire, ); std.debug.assert(previous == null); while (active_operations.load(.acquire) != 0) { std.atomic.spinLoopHint(); } self.active = false; self.sink = null; } /// Reports the next producer identifier captured during session /// installation under the registry lock, or zero when observation is /// disabled. This boundary value separates producers registered prior to /// installation from those registered subsequently. Falling at or above /// this threshold indicates registration after the session began, but does /// not prove that an emitter event history is complete, because thread /// suppression or incomplete sink coverage may have omitted events. pub fn producerIdFloor(self: *const Session) u64 { if (comptime !enabled) return 0; return self.producer_id_floor; }};Source: lib/alloc/observe/src/root.zig:416
zig
/// Represents an installed observation interval, managing session duration/// while borrowing caller-owned sink and context storage. Callers must ensure/// sink and context storage remain allocated at stable memory addresses/// throughout the session. The session must be explicitly terminated by calling/// deinit exactly once, as no automatic teardown is performed on drop. In/// disabled builds, the session is inert. Callers must serialize session/// lifecycle transitions externally, because the protocol does not support/// overlapping the shutdown of an old session with the installation of a new/// one.pub const Session = protocol.Session;Audit
| Definitions | 3 |
|---|---|
| Public names | 3 |
| Members | 3 |
| Version | 26.7.0 |
| Revision | daab053ee433 |