pub struct FrameRegion { /* private fields */ }Expand description
Concurrent fixed-block region. Multi-producer alloc,
multi-consumer free, any-order reclaim.
Implementations§
Source§impl FrameRegion
impl FrameRegion
Sourcepub fn create_anon(
block_size: usize,
block_count: usize,
) -> Result<Self, RingError>
pub fn create_anon( block_size: usize, block_count: usize, ) -> Result<Self, RingError>
Anonymous in-process region.
Sourcepub fn create(
path: impl AsRef<Path>,
block_size: usize,
block_count: usize,
) -> Result<Self, RingError>
pub fn create( path: impl AsRef<Path>, block_size: usize, block_count: usize, ) -> Result<Self, RingError>
File-backed region; cross-process via the page cache.
Sourcepub fn open(
path: impl AsRef<Path>,
block_size: usize,
block_count: usize,
) -> Result<Self, RingError>
pub fn open( path: impl AsRef<Path>, block_size: usize, block_count: usize, ) -> Result<Self, RingError>
Open an existing file-backed region. Validates the header.
Sourcepub fn create_from_shm(
shm: ShmFile,
block_size: usize,
block_count: usize,
) -> Result<Self, RingError>
pub fn create_from_shm( shm: ShmFile, block_size: usize, block_count: usize, ) -> Result<Self, RingError>
Build a region on a named RAM-resident shared-memory backing.
Sourcepub fn open_from_shm(
shm: ShmFile,
block_size: usize,
block_count: usize,
) -> Result<Self, RingError>
pub fn open_from_shm( shm: ShmFile, block_size: usize, block_count: usize, ) -> Result<Self, RingError>
Open an existing named ShmFs-backed region (no re-init).
Sourcepub fn create_or_open_shm(
name: &str,
block_size: usize,
block_count: usize,
) -> Result<Self, RingError>
pub fn create_or_open_shm( name: &str, block_size: usize, block_count: usize, ) -> Result<Self, RingError>
Create-or-open a named ShmFs frame region. The first attacher
CAS-initialises the layout and publishes the magic; racing
attachers spin until it lands, so a late-joining consumer never
wipes a region a producer already filled. This is the shared
payload region the cross-process offset-frame path needs: the
producer create-or-opens it on the first offset send_frame,
and every consumer create-or-opens the SAME region on the first
offset recv_frame (the descriptor it popped implies the
producer already created it).
Sourcepub fn create_or_open_file(
path: impl AsRef<Path>,
block_size: usize,
block_count: usize,
) -> Result<Self, RingError>
pub fn create_or_open_file( path: impl AsRef<Path>, block_size: usize, block_count: usize, ) -> Result<Self, RingError>
Create-or-open a file-backed frame region: the file-locale peer
of create_or_open_shm, for rings
backed by [AdaptiveRing::create] / open.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Largest payload a block holds.
Sourcepub fn block_count(&self) -> usize
pub fn block_count(&self) -> usize
Number of blocks.
Sourcepub fn alloc(&self) -> Option<u32>
pub fn alloc(&self) -> Option<u32>
Allocate a block. Free list first, then bump. None when full.
Sourcepub fn write_block(&self, idx: u32, payload: &[u8])
pub fn write_block(&self, idx: u32, payload: &[u8])
Copy payload into block idx. Caller guarantees
payload.len() <= block_size.