UNISTDX_IPC_SHARED_MEMORY_SEGMENT
using shm_type = int

Alias for shared memory ID type.

enum shm_flags_type
  • huge_pages = SHM_HUGETLB
  • huge_2mb = SHM_HUGE_2MB
  • huge_1gb = SHM_HUGE_1GB
  • no_reserve = SHM_NORESERVE
enum ipc_mode_type
  • create = IPC_CREAT
  • exclusive = IPC_EXCL
  • no_wait = IPC_NOWAIT
class sys::shared_memory_segment_status

A wrapper for shmid_ds system structure.

Base classes
  • public shmid_ds
Types
  • using size_type = std::size_t

    Size type. Alias to std::size_t.

  • using num_attaches_type = ::shmatt_t

    Return type of num_attaches.

  • using tp_type = clock_type::time_point

    Return type of last_attach.

  • using clock_type = std::chrono::system_clock

    Clock type used in this class.

Methods
  • num_attaches() const -> num_attaches_type

    The current number of attaches.

  • last_change() const -> tp_type

    Last change time.

  • last_detach() const -> tp_type

    Last detach time.

  • last_attach() const -> tp_type

    Last attach time.

  • last_user() const -> pid_type

    The last process that accessed this segment.

  • creator() const -> pid_type

    The process that created this segment.

  • segment_size() const -> size_type

    Size of shared memory segment in bytes.

  • shared_memory_segment_status(shm_type id)explicit

    Get status for shared memory segment with ID id.

    bad_call

    See
    shmctl(2)
template <class T>
class sys::shared_memory_segment

A container that stores its elements in shared memory.

  • Elements can be accessed in both parent and child processes.
  • The container does not provide syncrhonisation.

Types
  • using iterator = T *

    Container iterator type.

  • using value_type = T

    Container element type.

  • using addr_type = void *

    Raw pointer type.

  • using size_type = std::size_t

    Size type. Alias to std::size_t.

Fields
  • const typedef T * const_iterator

    Container const iterator type.

Methods
  • close() -> void

    Detach and remove (if owner) shared memory segment.

    bad_call

    See
    shmdt(2)
    See
    shmctl(2)
  • open_as_owner(mode_type mode, size_type size) -> void

    Create and attach shared memory segment.

    bad_call

    See
    shmget(2)
    See
    shmat(2)
  • open_as_user(shm_type id) -> void

    Attach shared memory segment.

    bad_call

    See
    shmat(2)
    See
    shmctl(2)
  • operator!=(const shared_memory_segment & rhs) const -> bool

    Compare shared memory segments element-wise. ID is not important.

    Return
    false if segments have the same size and the same elements
  • operator==(const shared_memory_segment & rhs) const -> bool

    Compare shared memory segments element-wise. ID is not important.

    Return
    true if segments have the same size and the same elements
  • operator!() const -> bool

    Checks if the segement is attached.

    Return
    false if the segment is attached
  • operator bool() constexplicit

    Checks if the segement is attached.

    Return
    true if the segment is attached
  • id() const -> shm_type

    Get segment ID.

  • end() const -> const_iterator

    Returns iterator to the end of the container.

  • begin() const -> const_iterator

    Returns iterator to the beginning of the container.

  • end() -> iterator

    Returns iterator to the end of the container.

  • begin() -> iterator

    Returns iterator to the beginning of the container.

  • owner() const -> bool

    Check if the segment is owned by this process.

  • size_in_bytes() const -> size_type

    Get the size of shared memory segment in bytes.

  • size() const -> size_type

    Get the number of elements in the container.

  • ptr() const -> addr_type

    Get raw pointer to the contents of shared memory segment.

  • ptr() -> addr_type

    Get raw pointer to the contents of shared memory segment.

  • swap(shared_memory_segment & rhs) -> void

    Swap with rhs.

  • operator=(shared_memory_segment && rhs) -> shared_memory_segment &

    Move-assigment.

  • operator=(const shared_memory_segment &) -> shared_memory_segment &
  • ~shared_memory_segment()

    Terminates on system error.

  • shared_memory_segment(const shared_memory_segment &)
  • shared_memory_segment()
  • shared_memory_segment(shared_memory_segment && rhs)

    Move-constructor.

  • shared_memory_segment(shm_type shm)explicit

    Attach shared memory segment with id shm.

    See
    shmat(2)
  • shared_memory_segment(mode_type mode, size_type guaranteed_size)

    Create and attach shared memory segment with mode mode and minimum size guaranteed_size.

    bad_call

    See
    shmget(2)
    See
    shmat(2)
template <class T>
swap(shared_memory_segment< T > & lhs, shared_memory_segment< T > & rhs) -> void

Overload of std::swap for shared_memory_segment.