geopm 3.2.1.dev535+ga96c120fc
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
geopm::SharedMemoryImp Class Reference

#include <SharedMemoryImp.hpp>

Inheritance diagram for geopm::SharedMemoryImp:
Collaboration diagram for geopm::SharedMemoryImp:

Public Member Functions

 SharedMemoryImp ()
virtual ~SharedMemoryImp ()
 Destructor destroys and unlinks the shared memory region.
 SharedMemoryImp (SharedMemoryImp &other)=delete
SharedMemoryImp & operator= (const SharedMemoryImp &other)=delete
void * pointer (void) const override
 Retrieve a pointer to the shared memory region.
std::string key (void) const override
 Retrieve the key to the shared memory region.
size_t size (void) const override
 Retrieve the size of the shared memory region.
void unlink (void) override
 Unlink the shared memory region.
std::unique_ptr< SharedMemoryScopedLock > get_scoped_lock (void) override
 Attempt to lock the mutex for the shared memory region and return a scoped mutex object that will unlock the mutex when it goes out of scope.
void create_memory_region (const std::string &shm_key, size_t size, bool is_secure)
 Takes a key and a size and creates an inter-process shared memory region.
void attach_memory_region (const std::string &shm_key, unsigned int timeout)
 Takes a key and attempts to attach to a inter-process shared memory region. This version of the constructor tries to attach multiple times until a timeout is reached.
void chown (const unsigned int uid, const unsigned int gid) const override
 Modifies the shared memory to be owned by the specified gid.
Public Member Functions inherited from geopm::SharedMemory
 SharedMemory ()=default
 SharedMemory (const SharedMemory &other)=default
SharedMemory & operator= (const SharedMemory &other)=default
virtual ~SharedMemory ()=default

Static Public Member Functions

static std::string construct_shm_path (const std::string &key)
 Construct the file path to use for the provided key.
Static Public Member Functions inherited from geopm::SharedMemory
static std::unique_ptr< SharedMemory > make_unique_owner (const std::string &shm_key, size_t size)
 Creates a shared memory region with the given key and size.
static std::unique_ptr< SharedMemory > make_unique_owner_secure (const std::string &shm_key, size_t size)
 Creates a shared memory region with the given key and size without group or world permissions.
static std::unique_ptr< SharedMemory > make_unique_user (const std::string &shm_key, unsigned int timeout)
 Attaches to the shared memory region with the given key.
static void cleanup_shmem (void)

Constructor & Destructor Documentation

◆ SharedMemoryImp() [1/2]

geopm::SharedMemoryImp::SharedMemoryImp ( )

◆ ~SharedMemoryImp()

geopm::SharedMemoryImp::~SharedMemoryImp ( )
virtual

Destructor destroys and unlinks the shared memory region.

◆ SharedMemoryImp() [2/2]

geopm::SharedMemoryImp::SharedMemoryImp ( SharedMemoryImp & other)
delete

Member Function Documentation

◆ attach_memory_region()

void geopm::SharedMemoryImp::attach_memory_region ( const std::string & shm_key,
unsigned int timeout )

Takes a key and attempts to attach to a inter-process shared memory region. This version of the constructor tries to attach multiple times until a timeout is reached.

Parameters
[in]shm_keyShared memory key to attach to the region.
[in]timeoutLength in seconds to keep retrying the attachment process to a shared memory region.

◆ chown()

void geopm::SharedMemoryImp::chown ( const unsigned int uid,
const unsigned int gid ) const
overridevirtual

Modifies the shared memory to be owned by the specified gid.

Parameters
[in]uidUser ID to become owner.
[in]gidGroup ID to become owner.

Implements geopm::SharedMemory.

◆ construct_shm_path()

std::string geopm::SharedMemoryImp::construct_shm_path ( const std::string & key)
static

Construct the file path to use for the provided key.

◆ create_memory_region()

void geopm::SharedMemoryImp::create_memory_region ( const std::string & shm_key,
size_t size,
bool is_secure )

Takes a key and a size and creates an inter-process shared memory region.

Parameters
[in]shm_keyShared memory key to create the region.
[in]sizeSize of the region to create.
[in]is_secureDisallow group and world r/w if true.

◆ get_scoped_lock()

std::unique_ptr< SharedMemoryScopedLock > geopm::SharedMemoryImp::get_scoped_lock ( void )
overridevirtual

Attempt to lock the mutex for the shared memory region and return a scoped mutex object that will unlock the mutex when it goes out of scope.

This method should be called before accessing the memory with pointer()

Implements geopm::SharedMemory.

◆ key()

std::string geopm::SharedMemoryImp::key ( void ) const
overridevirtual

Retrieve the key to the shared memory region.

Returns
Key to the shared memory region.

Implements geopm::SharedMemory.

◆ operator=()

SharedMemoryImp & geopm::SharedMemoryImp::operator= ( const SharedMemoryImp & other)
delete

◆ pointer()

void * geopm::SharedMemoryImp::pointer ( void ) const
overridevirtual

Retrieve a pointer to the shared memory region.

Returns
Void pointer to the shared memory region.

Implements geopm::SharedMemory.

◆ size()

size_t geopm::SharedMemoryImp::size ( void ) const
overridevirtual

Retrieve the size of the shared memory region.

Returns
Size of the shared memory region.

Implements geopm::SharedMemory.

◆ unlink()

void geopm::SharedMemoryImp::unlink ( void )
overridevirtual

Unlink the shared memory region.

Implements geopm::SharedMemory.


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