pub struct InMemorySlotAllocator { /* private fields */ }Expand description
In-Memory-Slot-Allocator. Vermittelt das gleiche
SlotBackend-Interface wie der
POSIX-mmap-Backend (posix.rs), aber liegt im Process-Heap —
Single-Process-Pub/Sub und Test-Setups ohne mmap-Dep.
Implementations§
Source§impl InMemorySlotAllocator
impl InMemorySlotAllocator
Sourcepub fn new(segment_id: u64, slot_count: usize, slot_capacity: usize) -> Self
pub fn new(segment_id: u64, slot_count: usize, slot_capacity: usize) -> Self
Erzeugt einen neuen Allocator mit slot_count Slots zu je
slot_capacity Bytes Daten-Bereich.
Sourcepub fn with_type_hash(self, hash: [u8; 16]) -> Self
pub fn with_type_hash(self, hash: [u8; 16]) -> Self
Spec §6.1: Allocator mit verbundenem Type-Hash. Reader, der
gegen diesen Backend liest, prueft den Hash gegen
T::TYPE_HASH und droppt bei Mismatch.
Sourcepub fn reserve_slot(
&self,
active_readers_mask: ReaderMask,
) -> Result<SlotHandle, SlotError>
pub fn reserve_slot( &self, active_readers_mask: ReaderMask, ) -> Result<SlotHandle, SlotError>
Spec §4.1 reserve_slot. Sucht einen freien Slot (alle aktiven Reader haben gelesen) oder den ersten unbenutzten.
§Errors
NoFreeSlot wenn alle Slots geloant oder unfertig.
Sourcepub fn commit_slot(
&self,
handle: SlotHandle,
bytes: &[u8],
) -> Result<u32, SlotError>
pub fn commit_slot( &self, handle: SlotHandle, bytes: &[u8], ) -> Result<u32, SlotError>
Spec §4.1 commit_slot. Schreibt sample-bytes in den Slot und setzt SlotHeader { sn, sample_size, reader_mask=0 }.
§Errors
OutOfBounds, SampleTooLarge, oder Lock-Poison.
Sourcepub fn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>
pub fn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>
Sourcepub fn read_slot(
&self,
handle: SlotHandle,
) -> Result<(SlotHeader, Vec<u8>), SlotError>
pub fn read_slot( &self, handle: SlotHandle, ) -> Result<(SlotHeader, Vec<u8>), SlotError>
Sourcepub fn mark_reader_disconnected(
&self,
reader_index: u8,
) -> Result<(), SlotError>
pub fn mark_reader_disconnected( &self, reader_index: u8, ) -> Result<(), SlotError>
Spec §5.2 Reader-Disconnect retroaktiv.
Wird vom Caller (SPDP-Lease-Expiry-Hook) gerufen wenn ein Reader gestorben ist. Setzt sein Bit auf allen Slots, damit der Slot-Allocator ihn als “hat gelesen” sieht und belegte Slots wieder freigibt.
§Errors
Lock-Poison.
Sourcepub fn slot_capacity(&self) -> usize
pub fn slot_capacity(&self) -> usize
Slot-Capacity (data-Bereich; ohne Header).
Sourcepub fn slot_count(&self) -> Result<usize, SlotError>
pub fn slot_count(&self) -> Result<usize, SlotError>
Anzahl konfigurierter Slots.
Sourcepub fn slot_total_size(&self) -> usize
pub fn slot_total_size(&self) -> usize
Berechnet die Gesamt-Slot-Groesse (Header + Daten, gepaddet auf 64-byte Cache-Line) — fuer SEDP-Discovery.
Trait Implementations§
Source§impl SlotBackend for InMemorySlotAllocator
Available on crate feature std only.
impl SlotBackend for InMemorySlotAllocator
std only.Source§fn reserve_slot(
&self,
active_readers_mask: ReaderMask,
) -> Result<SlotHandle, SlotError>
fn reserve_slot( &self, active_readers_mask: ReaderMask, ) -> Result<SlotHandle, SlotError>
commit_slot und veroeffentlicht damit das Sample. Read moreSource§fn commit_slot(
&self,
handle: SlotHandle,
bytes: &[u8],
) -> Result<u32, SlotError>
fn commit_slot( &self, handle: SlotHandle, bytes: &[u8], ) -> Result<u32, SlotError>
{ sn, sample_size, reader_mask=0 }. Liefert die SN. Read moreSource§fn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>
fn discard_slot(&self, handle: SlotHandle) -> Result<(), SlotError>
Source§fn read_slot(
&self,
handle: SlotHandle,
) -> Result<(SlotHeader, Vec<u8>), SlotError>
fn read_slot( &self, handle: SlotHandle, ) -> Result<(SlotHeader, Vec<u8>), SlotError>
Source§fn mark_reader_disconnected(&self, reader_index: u8) -> Result<(), SlotError>
fn mark_reader_disconnected(&self, reader_index: u8) -> Result<(), SlotError>
reader_index-Bit retroaktiv auf allen Slots
(SPDP-Lease-Expiry). Read more