pub trait ShMemProvider: Clone + Default + Debug {
    type ShMem: ShMem;

    fn new() -> Result<Self, Error>;
    fn new_shmem(&mut self, map_size: usize) -> Result<Self::ShMem, Error>;
    fn shmem_from_id_and_size(
        &mut self,
        id: ShMemId,
        size: usize
    ) -> Result<Self::ShMem, Error>; fn new_shmem_object<T: Sized + 'static>(
        &mut self
    ) -> Result<Self::ShMem, Error> { ... } fn shmem_object_from_id<T: Sized + 'static>(
        &mut self,
        id: ShMemId
    ) -> Result<Self::ShMem, Error> { ... } fn shmem_from_description(
        &mut self,
        description: ShMemDescription
    ) -> Result<Self::ShMem, Error> { ... } fn clone_ref(&mut self, mapping: &Self::ShMem) -> Result<Self::ShMem, Error> { ... } fn existing_from_env(&mut self, env_name: &str) -> Result<Self::ShMem, Error> { ... } fn pre_fork(&mut self) -> Result<(), Error> { ... } fn post_fork(&mut self, _is_child: bool) -> Result<(), Error> { ... } fn release_shmem(&mut self, _shmem: &mut Self::ShMem) { ... } }
Expand description

A ShMemProvider provides access to shared maps. They are the backbone of crate::bolts::llmp for inter-process communication. All you need for scaling on a new target is to implement this interface, as well as the respective ShMem.

Required Associated Types§

source

type ShMem: ShMem

The actual shared map handed out by this ShMemProvider.

Required Methods§

source

fn new() -> Result<Self, Error>

Create a new instance of the provider

source

fn new_shmem(&mut self, map_size: usize) -> Result<Self::ShMem, Error>

Create a new shared memory mapping

source

fn shmem_from_id_and_size(
    &mut self,
    id: ShMemId,
    size: usize
) -> Result<Self::ShMem, Error>

Get a mapping given its id and size

Provided Methods§

source

fn new_shmem_object<T: Sized + 'static>(&mut self) -> Result<Self::ShMem, Error>

Create a new shared memory mapping to hold an object of the given type

source

fn shmem_object_from_id<T: Sized + 'static>(
    &mut self,
    id: ShMemId
) -> Result<Self::ShMem, Error>

Get a mapping given its id to hold an object of the given type

source

fn shmem_from_description(
    &mut self,
    description: ShMemDescription
) -> Result<Self::ShMem, Error>

Get a mapping given a description

source

fn clone_ref(&mut self, mapping: &Self::ShMem) -> Result<Self::ShMem, Error>

Create a new sharedmap reference from an existing id and len

source

fn existing_from_env(&mut self, env_name: &str) -> Result<Self::ShMem, Error>

Reads an existing map config from env vars, then maps it

source

fn pre_fork(&mut self) -> Result<(), Error>

This method should be called before a fork or a thread creation event, allowing the ShMemProvider to get ready for a potential reset of thread specific info, and for potential reconnects. Make sure to call Self::post_fork() after threading!

source

fn post_fork(&mut self, _is_child: bool) -> Result<(), Error>

This method should be called after a fork or after cloning/a thread creation event, allowing the ShMemProvider to reset thread specific info, and potentially reconnect. Make sure to call Self::pre_fork() before threading!

source

fn release_shmem(&mut self, _shmem: &mut Self::ShMem)

Release the resources associated with the given ShMem

Implementors§