Skip to main content

SharedHandler

Struct SharedHandler 

Source
pub struct SharedHandler { /* private fields */ }
Expand description

A lightweight reflection of the original handler that can be safely sent across threads.

Produced by MatrixHandler::share(). Holds raw pointers into the SHM segment. The originating MatrixHandler must outlive all SharedHandler instances derived from it.

SharedHandler exposes the same allocation, I/O, lifecycle, and escape hatch API as MatrixHandler via the HandlerFunctions trait — it does not own the mmap.

Trait Implementations§

Source§

impl HandlerFunctions for SharedHandler

Source§

fn base_ptr(&self) -> *const u8

Returns the SHM base pointer for this process’s mapping.
Source§

fn matrix(&self) -> &AtomicMatrix

Returns a reference to the underlying AtomicMatrix.
Source§

fn first_block_offset(&self) -> u32

Returns the offset of the first data block in the segment. Used by internals iterators as the physical chain walk start point.
Source§

fn segment_size(&self) -> u32

Returns the total segment size in bytes.
Source§

fn allocate<T>(&self) -> Result<Block<T>, HandlerError>

Allocates a block sized to hold T. Read more
Source§

fn allocate_raw(&self, size: u32) -> Result<RelativePtr<u8>, HandlerError>

Allocates a raw byte block of the given size. Read more
Source§

unsafe fn write<T>(&self, block: &mut Block<T>, value: T)

Writes a value of type T into an allocated block. Read more
Source§

unsafe fn read<'a, T>(&self, block: &Block<T>) -> &'a T

Reads a shared reference to T from an allocated block. Read more
Source§

unsafe fn read_mut<'a, T>(&self, block: &Block<T>) -> &'a mut T

Reads a mutable reference to T from an allocated block. Read more
Source§

fn free<T>(&self, block: Block<T>)

Frees a typed block. Read more
Source§

fn free_at(&self, header_offset: u32)

Frees a block by its header offset directly. Read more
Source§

fn set_state<T>(&self, block: &Block<T>, state: u32) -> Result<(), HandlerError>

Sets a user-defined lifecycle state on a block. Read more
Source§

fn get_state<T>(&self, block: &Block<T>, order: Ordering) -> u32

Returns the current state of a block. Read more
Source§

fn transition_state<T>( &self, block: &Block<T>, expected: u32, next: u32, success_order: Ordering, ) -> Result<u32, HandlerError>

Atomically transitions a block from one state to another. Read more
Source§

fn raw_matrix(&self) -> &AtomicMatrix

Returns a raw reference to the underlying AtomicMatrix. Read more
Source§

fn raw_base_ptr(&self) -> *const u8

Returns the raw SHM base pointer for this process’s mapping. Read more
Source§

impl Send for SharedHandler

Source§

impl Sync for SharedHandler

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.