Struct shared_memory::SharedMem [] [src]

pub struct SharedMem<'a> { /* fields omitted */ }

Struct used to manipulate the shared memory

Methods

impl<'a> SharedMem<'a>
[src]

[src]

Creates a new SharedMem

This involves creating a "link" on disk specified by the first parameter. This link contains the OS specific identifier to the shared memory. The usage of such link files on disk help manage identifier colisions. (ie: a binary using the same argument to this function can be ran from different directories without worrying about collisions)

Examples

//Creates a new shared SharedMem named shared_mem.link of size 4096
let mut my_shmem: SharedMem = match SharedMem::create(PathBuf::from("shared_mem.link"), LockType::Mutex, 4096) {
    Ok(v) => v,
    Err(e) => {
        println!("Error : {}", e);
        println!("Failed to create SharedMem...");
        return;
    }
};

[src]

Opens an existing SharedMem

This function takes a path to a link file created by create(). Open() will automatically detect the size and locking mechanisms.

Examples

use shared_memory::*;
//Opens an existing shared SharedMem named test.txt
let mut my_shmem: SharedMem = match SharedMem::open(PathBuf::from("shared_mem.link")) {
    Ok(v) => v,
    Err(e) => {
        println!("Error : {}", e);
        println!("Failed to open SharedMem...");
        return;
    }
};

[src]

Creates a raw shared memory object. Only use this method if you do not wish to have all the nice features of a regular SharedMem.

This function is useful when creating mappings for libraries/applications that do not use SharedMem. By using this function, you explicitly mean : do not create anything else than a memory mapping.

The first argument needs to be a valid identifier for the OS in use. colisions wont be avoided through link files and no meta data (locks) is added to the shared mapping.

[src]

Opens an existing shared memory mappping in raw mode. This simply opens an existing mapping with no additionnal features (no locking, no metadata, etc...).

This function is useful when using mappings not created by my_shmem.

To use this function, you need to pass a valid OS shared memory identifier as an argument.

[src]

Returns the size of the SharedMem

Returns the link_path of the SharedMem

[src]

Returns the OS specific path of the shared memory object

Usualy on Linux, this will point to a file under /dev/shm/

On Windows, this returns a namespace

Trait Implementations

impl<'a> SharedMemLockable for SharedMem<'a>
[src]

[src]

Returns a read lock to the shared memory Read more

[src]

Returns a read lock to the shared memory as a slice Read more

[src]

Returns a read/write lock to the shared memory # Examples Read more

[src]

Returns a read/write access to a &mut [T] on the shared memory Read more

impl<'a> Drop for SharedMem<'a>
[src]

[src]

Deletes the SharedMem artifacts

Auto Trait Implementations

impl<'a> !Send for SharedMem<'a>

impl<'a> !Sync for SharedMem<'a>