silk.trace.storage.

Pinned, preallocated storage for independently claimed recorder slots.

Import as Storage with import silk.trace.storage { Storage }.

Public declarations: 4.

Storage#

silk
pub struct Storage<T>

The owner prevents reallocation or release until every operation has finished.

Field length#

silk
pub length: usize

Implementation Storage<T>#

silk
impl<T: Copy> Storage<T>

Associated function make#

silk
pub effect fn make(count: usize, initial: T) -> Self ! OutOfMemoryError ? &mut Allocator

Allocates and initializes every cell before publishing the recorder.

Method at#

silk
pub unsafe fn at(self: &Self, index: usize) -> *mut T

The caller owns the slot or accesses it only through atomics.

Slots#

silk
pub struct Slots<T>

A bounded set of cells. Independent atomic states protect disjoint payloads.

Implementation Slots<T>#

silk
impl<T: Copy> Slots<T>

Associated function make#

silk
pub effect fn make(count: usize, initial: T) -> Self ! OutOfMemoryError ? &mut Allocator

Allocates all cells before observation starts.

Method length#

silk
pub fn length(self: &Self) -> usize

The configured number of slots.

Method claimAt#

silk
pub fn claimAt(self: &Self, index: usize, from: u32, to: u32) -> bool

Claims a single cell when its state still matches the caller's observation.

Method claim#

silk
pub fn claim(self: &Self, first: usize, from: u32, to: u32) -> usize

Attempts one bounded sweep. Returns the capacity when no matching cell is available.

Method at#

silk
pub unsafe fn at(self: &Self, index: usize) -> *mut T

The caller holds an exclusive claim for this index.

Method publish#

silk
pub fn publish(self: &Self, index: usize, state: u32) -> ()

Publishes the payload to a consumer or returns the cell to producers.

Buffers#

silk
pub struct Buffers<T>

A pool of producer buffers with release/acquire handoff of full and partial pages.

Implementation Buffers<T>#

silk
impl<T: Copy> Buffers<T>

Associated function make#

silk
pub effect fn make(count: usize, width: usize, initial: T) -> Self ! OutOfMemoryError ? &mut Allocator

Allocates all page headers and all record slots.

Method length#

silk
pub fn length(self: &Self) -> usize

The maximum number of buffered records.

Method append#

silk
pub fn append(self: &Self, hint: &mut usize, owner: usize, value: &T) -> bool

Appends to the worker's partial page or acquires a fresh one. No thread waits for a peer.

Method take#

silk
pub unsafe fn take(self: &Self, hint: *mut u64) -> Option<T>

Drains ready pages before sealing a partial page. The next consumer can continue a page. The caller supplies a live atomic word for the entire call. All concurrent accesses to it must be atomic.

Pool#

silk
pub struct Pool<T>

A bounded open-record pool with a lock-free free stack for cross-thread returns.

Implementation Pool<T>#

silk
impl<T: Copy> Pool<T>

Associated function make#

silk
pub effect fn make(capacity: usize, initial: T) -> Self ! OutOfMemoryError ? &mut Allocator

Allocates the records and links the available cells.

Method length#

silk
pub fn length(self: &Self) -> usize

The number of cells configured for open spans.

Method acquire#

silk
pub fn acquire(self: &Self) -> usize

Pops an open cell. Exhaustion returns the capacity as an out-of-range index.

Method at#

silk
pub unsafe fn at(self: &Self, index: usize) -> *mut T

Only the opener of this record may read or write it until release.

Method indexOf#

silk
pub fn indexOf(self: &Self, address: u64) -> usize

Resolves a stored machine address to a slot, rejecting addresses outside this pool or in the middle of a record. The address stays wide enough on 32-bit WebAssembly.

Method release#

silk
pub fn release(self: &Self, index: usize) -> ()

Releases a record even when its closing fiber runs on another worker.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.

View the source of this page