Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
Realm::SharedMemoryInfo Class Reference

Holds a reference to a mapped shared memory region and all the information used to create/open it. Such shared memory region can be shared with other processes on the same system using a communication mechanism such as via unix domain sockets, win32 DuplicateHandle, or if names are used, transferring the names to the processes and opening them (. More...

#include <shm.h>

Public Member Functions

 SharedMemoryInfo (void)
 
 ~SharedMemoryInfo (void)
 On destruction, the SharedMemoryInfo will unmap the memory associated with this shared region, if any, and unlink it from the file system if it owns it.
 
 SharedMemoryInfo (const SharedMemoryInfo &)=delete
 
SharedMemoryInfooperator= (const SharedMemoryInfo &)=delete
 
void unlink (void)
 Removes the name from the shared memory region such that it can't be opened by it's name any more and closes the associated handle.
 
Move semantics
 SharedMemoryInfo (SharedMemoryInfo &&other)
 
SharedMemoryInfooperator= (SharedMemoryInfo &&other)
 
Accessors
template<typename T >
T * get_ptr () const
 
OsHandle get_handle () const
 
size_t get_size () const
 
std::string get_name () const
 
 operator bool () const
 

Static Public Member Functions

static bool create (SharedMemoryInfo &info, size_t size, const char *name=nullptr, int numa_node=-1)
 Creates a shared memory region accessible via handle.
 
static bool open (SharedMemoryInfo &info, const std::string &name, size_t size)
 Opens a previously created shared memory region given it's name and size.
 
static bool open (SharedMemoryInfo &info, OsHandle handle, size_t size)
 Opens a previously created shared memory region given it's associated handle and size.
 

Detailed Description

Holds a reference to a mapped shared memory region and all the information used to create/open it. Such shared memory region can be shared with other processes on the same system using a communication mechanism such as via unix domain sockets, win32 DuplicateHandle, or if names are used, transferring the names to the processes and opening them (.

See also
SharedMemoryInfo::open)

Constructor & Destructor Documentation

◆ SharedMemoryInfo() [1/3]

Realm::SharedMemoryInfo::SharedMemoryInfo ( void  )

◆ SharedMemoryInfo() [2/3]

Realm::SharedMemoryInfo::SharedMemoryInfo ( SharedMemoryInfo &&  other)

◆ ~SharedMemoryInfo()

Realm::SharedMemoryInfo::~SharedMemoryInfo ( void  )

On destruction, the SharedMemoryInfo will unmap the memory associated with this shared region, if any, and unlink it from the file system if it owns it.

◆ SharedMemoryInfo() [3/3]

Realm::SharedMemoryInfo::SharedMemoryInfo ( const SharedMemoryInfo )
delete

Member Function Documentation

◆ create()

static bool Realm::SharedMemoryInfo::create ( SharedMemoryInfo info,
size_t  size,
const char *  name = nullptr,
int  numa_node = -1 
)
static

Creates a shared memory region accessible via handle.

Note
It is preferred that the name is null here as this creates an anonymous backing store that requires processor-to-processor communication.
Parameters
[out]infoShared memory object containing the base pointer and size
nameName associated with the shared memory allocation, passed to
See also
SharedMemoryInfo::open in another process.
Parameters
sizeSize of the shared memory region to allocate
numa_nodeNUMA node to allocate the pages on
Returns
True on success, false otherwise

◆ get_handle()

OsHandle Realm::SharedMemoryInfo::get_handle ( ) const
inline

◆ get_name()

std::string Realm::SharedMemoryInfo::get_name ( ) const
inline

◆ get_ptr()

template<typename T >
T * Realm::SharedMemoryInfo::get_ptr ( ) const
inline

◆ get_size()

size_t Realm::SharedMemoryInfo::get_size ( ) const
inline

◆ open() [1/2]

static bool Realm::SharedMemoryInfo::open ( SharedMemoryInfo info,
const std::string &  name,
size_t  size 
)
static

Opens a previously created shared memory region given it's name and size.

Parameters
[out]infoShared memory object containing the base pointer and size
nameName of the shared memory region (to be retrieved from
See also
SharedMemoryInfo::create in another process)
Parameters
sizeSize of the shared memory region to allocate
Returns
True on success, false otherwise

◆ open() [2/2]

static bool Realm::SharedMemoryInfo::open ( SharedMemoryInfo info,
OsHandle  handle,
size_t  size 
)
static

Opens a previously created shared memory region given it's associated handle and size.

See also
Realm::close_handle
Parameters
[out]info
handleOS handle of the associated memory object (retrieved from
See also
SharedMemoryInfo::create)
Parameters
sizeSize of the shared memory region to allocate
Returns
True on success, false otherwise

◆ operator bool()

Realm::SharedMemoryInfo::operator bool ( ) const
inlineexplicit

◆ operator=() [1/2]

SharedMemoryInfo & Realm::SharedMemoryInfo::operator= ( const SharedMemoryInfo )
delete

◆ operator=() [2/2]

SharedMemoryInfo & Realm::SharedMemoryInfo::operator= ( SharedMemoryInfo &&  other)

◆ unlink()

void Realm::SharedMemoryInfo::unlink ( void  )

Removes the name from the shared memory region such that it can't be opened by it's name any more and closes the associated handle.

Note
not applicable to windows

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