geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
Public Member Functions | Static Public Member Functions | List of all members
geopm::SharedMemory Class Referenceabstract

This class encapsulates an inter-process shared memory region. More...

#include <SharedMemory.hpp>

Inheritance diagram for geopm::SharedMemory:
Inheritance graph
[legend]

Public Member Functions

 SharedMemory ()=default
 
 SharedMemory (const SharedMemory &other)=default
 
SharedMemoryoperator= (const SharedMemory &other)=default
 
virtual ~SharedMemory ()=default
 
virtual void * pointer (void) const =0
 Retrieve a pointer to the shared memory region. More...
 
virtual std::string key (void) const =0
 Retrieve the key to the shared memory region. More...
 
virtual size_t size (void) const =0
 Retrieve the size of the shared memory region. More...
 
virtual void unlink (void)=0
 Unlink the shared memory region. More...
 
virtual std::unique_ptr< SharedMemoryScopedLockget_scoped_lock (void)=0
 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...
 
virtual void chown (const unsigned int uid, const unsigned int gid) const =0
 Modifies the shared memory to be owned by the specified gid. More...
 

Static Public Member Functions

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)
 

Detailed Description

This class encapsulates an inter-process shared memory region.

Constructor & Destructor Documentation

◆ SharedMemory() [1/2]

geopm::SharedMemory::SharedMemory ( )
default

◆ SharedMemory() [2/2]

geopm::SharedMemory::SharedMemory ( const SharedMemory other)
default

◆ ~SharedMemory()

virtual geopm::SharedMemory::~SharedMemory ( )
virtualdefault

Member Function Documentation

◆ chown()

virtual void geopm::SharedMemory::chown ( const unsigned int  uid,
const unsigned int  gid 
) const
pure virtual

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

Implemented in geopm::SharedMemoryImp.

◆ cleanup_shmem()

void geopm::SharedMemory::cleanup_shmem ( void  )
static

◆ get_scoped_lock()

virtual std::unique_ptr<SharedMemoryScopedLock> geopm::SharedMemory::get_scoped_lock ( void  )
pure virtual

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()

Implemented in geopm::SharedMemoryImp.

◆ key()

virtual std::string geopm::SharedMemory::key ( void  ) const
pure virtual

Retrieve the key to the shared memory region.

Returns
Key to the shared memory region.

Implemented in geopm::SharedMemoryImp.

◆ make_unique_owner()

std::unique_ptr< SharedMemory > geopm::SharedMemory::make_unique_owner ( const std::string &  shm_key,
size_t  size 
)
static

Creates a shared memory region with the given key and size.

Returns
a pointer to a SharedMemory object managing the region.

◆ make_unique_owner_secure()

std::unique_ptr< SharedMemory > geopm::SharedMemory::make_unique_owner_secure ( const std::string &  shm_key,
size_t  size 
)
static

Creates a shared memory region with the given key and size without group or world permissions.

Returns
a pointer to a SharedMemory object managing the region.

◆ make_unique_user()

std::unique_ptr< SharedMemory > geopm::SharedMemory::make_unique_user ( const std::string &  shm_key,
unsigned int  timeout 
)
static

Attaches to the shared memory region with the given key.

Returns
a pointer to a SharedMemory object managing the region.
Exceptions
Ifit cannot attach within the timeout, throws an exception.

◆ operator=()

SharedMemory& geopm::SharedMemory::operator= ( const SharedMemory other)
default

◆ pointer()

virtual void* geopm::SharedMemory::pointer ( void  ) const
pure virtual

Retrieve a pointer to the shared memory region.

Returns
Void pointer to the shared memory region.

Implemented in geopm::SharedMemoryImp.

◆ size()

virtual size_t geopm::SharedMemory::size ( void  ) const
pure virtual

Retrieve the size of the shared memory region.

Returns
Size of the shared memory region.

Implemented in geopm::SharedMemoryImp.

◆ unlink()

virtual void geopm::SharedMemory::unlink ( void  )
pure virtual

Unlink the shared memory region.

Implemented in geopm::SharedMemoryImp.


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