geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Public Member Functions | Static Public Member Functions | List of all members
geopm::SharedMemoryImp Class Reference

#include <SharedMemoryImp.hpp>

Inheritance diagram for geopm::SharedMemoryImp:
Inheritance graph
[legend]
Collaboration diagram for geopm::SharedMemoryImp:
Collaboration graph
[legend]

Public Member Functions

 SharedMemoryImp ()
 
virtual ~SharedMemoryImp ()
 Destructor destroys and unlinks the shared memory region. More...
 
 SharedMemoryImp (SharedMemoryImp &other)=delete
 
SharedMemoryImpoperator= (const SharedMemoryImp &other)=delete
 
void * pointer (void) const override
 Retrieve a pointer to the shared memory region. More...
 
std::string key (void) const override
 Retrieve the key to the shared memory region. More...
 
size_t size (void) const override
 Retrieve the size of the shared memory region. More...
 
void unlink (void) override
 Unlink the shared memory region. More...
 
std::unique_ptr< SharedMemoryScopedLockget_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. More...
 
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. More...
 
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. More...
 
void chown (const unsigned int uid, const unsigned int gid) const override
 Modifies the shared memory to be owned by the specified gid. More...
 
- Public Member Functions inherited from geopm::SharedMemory
 SharedMemory ()=default
 
 SharedMemory (const SharedMemory &other)=default
 
SharedMemoryoperator= (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. More...
 
- Static Public Member Functions inherited from geopm::SharedMemory
static std::unique_ptr< SharedMemorymake_unique_owner (const std::string &shm_key, size_t size)
 Creates a shared memory region with the given key and size. More...
 
static std::unique_ptr< SharedMemorymake_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. More...
 
static std::unique_ptr< SharedMemorymake_unique_user (const std::string &shm_key, unsigned int timeout)
 Attaches to the shared memory region with the given key. More...
 
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: