libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::shared_mem Class Reference

A class to wrap POSIX (inter-process) shared-memory. More...

#include <shared_mem.hpp>

Public Types

enum  oflags_t : int {
  oflags_read_only =O_RDONLY , oflags_read_write =O_RDWR , oflags_create_if_not_exists =O_CREAT , oflags_exclusive_or_error =O_EXCL ,
  oflags_truncate_if_exists =O_TRUNC
}
 
enum  flags_t : int { flags_use_hugetlb =MAP_HUGETLB }
 
enum  mode_type : mode_t { mode_rwxrwxrwx =ACCESSPERMS , mode_srwxrwxrwx =ALLPERMS , mode_rwrwrw =DEFFILEMODE }
 
enum  protection_type : int { protection_read_only =PROT_READ , protection_read_write =PROT_READ|PROT_WRITE , protection_read_write_execte =PROT_READ|PROT_WRITE|PROT_EXEC }
 
enum  sync_flags_t : int { schedule_updates_return_immed =MS_ASYNC , req_update_wait =MS_SYNC }
 
using exception_type = crt_exception< ppd::platform_api, ppd::heavyweight_threading >
 
using handle_t = int
 
using oflags_type = std::underlying_type< oflags_t >::type
 

Public Member Functions

 shared_mem (std::string const &name, std::size_t length, oflags_type oflags=oflags_create_if_not_exists|oflags_read_write, mode_type mode=mode_rwrwrw, protection_type prot=protection_read_write) noexcept(false)
 
 ~shared_mem () noexcept(true)
 
template<class T >
T * get () noexcept(false)
 
template<class T >
T const * get () const noexcept(false)
 
void sync (void *addr, std::size_t length, sync_flags_t sync_flags=schedule_updates_return_immed) noexcept(false)
 
template<class T >
void sync (T *addr, sync_flags_t sync_flags=schedule_updates_return_immed) noexcept(false)
 

Detailed Description

A class to wrap POSIX (inter-process) shared-memory.

Definition at line 30 of file shared_mem.hpp.

Member Typedef Documentation

◆ exception_type

◆ handle_t

◆ oflags_type

Definition at line 42 of file shared_mem.hpp.

Member Enumeration Documentation

◆ flags_t

Enumerator
flags_use_hugetlb 

Requires kernel support and configuration.

Definition at line 43 of file shared_mem.hpp.

◆ mode_type

Enumerator
mode_rwxrwxrwx 
mode_srwxrwxrwx 
mode_rwrwrw 

Definition at line 50 of file shared_mem.hpp.

◆ oflags_t

Enumerator
oflags_read_only 
oflags_read_write 
oflags_create_if_not_exists 
oflags_exclusive_or_error 
oflags_truncate_if_exists 

Definition at line 35 of file shared_mem.hpp.

◆ protection_type

Enumerator
protection_read_only 
protection_read_write 
protection_read_write_execte 

Definition at line 55 of file shared_mem.hpp.

◆ sync_flags_t

Enumerator
schedule_updates_return_immed 
req_update_wait 

Definition at line 60 of file shared_mem.hpp.

Constructor & Destructor Documentation

◆ shared_mem()

jmmcg::LIBJMMCG_VER_NAMESPACE::shared_mem::shared_mem ( std::string const &  name,
std::size_t  length,
oflags_type  oflags = oflags_create_if_not_exists|oflags_read_write,
mode_type  mode = mode_rwrwrw,
protection_type  prot = protection_read_write 
)
noexcept

Definition at line 59 of file shared_mem.cpp.

References shared_mem().

Referenced by shared_mem().

◆ ~shared_mem()

jmmcg::LIBJMMCG_VER_NAMESPACE::shared_mem::~shared_mem ( )
noexcept

Definition at line 64 of file shared_mem.cpp.

Member Function Documentation

◆ get() [1/2]

template<class T >
T const * jmmcg::LIBJMMCG_VER_NAMESPACE::shared_mem::get
inlinenoexcept

Definition at line 105 of file shared_mem.hpp.

◆ get() [2/2]

template<class T >
T * jmmcg::LIBJMMCG_VER_NAMESPACE::shared_mem::get
inlinenoexcept

Definition at line 93 of file shared_mem.hpp.

◆ sync() [1/2]

template<class T >
void jmmcg::LIBJMMCG_VER_NAMESPACE::shared_mem::sync ( T *  addr,
sync_flags_t  sync_flags = schedule_updates_return_immed 
)
inlinenoexcept

Definition at line 117 of file shared_mem.hpp.

◆ sync() [2/2]

void jmmcg::LIBJMMCG_VER_NAMESPACE::shared_mem::sync ( void *  addr,
std::size_t  length,
sync_flags_t  sync_flags = schedule_updates_return_immed 
)
noexcept

Definition at line 78 of file shared_mem.cpp.


The documentation for this class was generated from the following files: