Shmex v0.1.2 Shmex View Source

This module allows using data placed in POSIX shared memory on POSIX compliant systems.

Defines a struct representing the actual shared memory object. The struct should not be modified, and should always be passed around as a whole - see Shmex.t/0

Link to this section Summary

Types

t()

Struct describing data kept in shared memory. Should not be modified and should always be passed around as a whole

Functions

Creates a new, empty shared memory area with the given capacity

Creates a new shared memory area filled with the existing data

Creates a new shared memory area initialized with data and sets its capacity

Sets the capacity of shared memory area

Link to this section Types

Link to this type t() View Source
t() :: %Shmex{
  capacity: pos_integer(),
  guard: reference(),
  name: binary(),
  size: non_neg_integer()
}

Struct describing data kept in shared memory. Should not be modified and should always be passed around as a whole

…including passing to the native code - there are functions in :shmex_lib (a native library exported via Bundlex) that will allow to transorm Elixir struct into a C struct and then access the shared memory from the native code.)

Shared memory should be available as long as the associated struct is not garbage collected.

Link to this section Functions

Link to this function empty(capacity \\ 4096) View Source
empty(capacity :: pos_integer()) :: t()

Creates a new, empty shared memory area with the given capacity

Creates a new shared memory area filled with the existing data.

Link to this function new(data, capacity) View Source
new(data :: binary(), capacity :: pos_integer()) :: t()

Creates a new shared memory area initialized with data and sets its capacity.

The actual capacity is the greater of passed capacity and data size

Link to this function set_capacity(shm, capacity) View Source
set_capacity(t(), pos_integer()) :: t()

Sets the capacity of shared memory area.

If the capacity is smaller than the current size, data will be discarded and size modified