lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lintel::SharedMemoryService Class Reference

#include <SharedMemoryService.h>

Inheritance diagram for lintel::SharedMemoryService:
lintel::PropertyRegistration< SharedMemoryService > lintel::ISharedMemoryService lintel::AbstractService< T > lintel::AbstractServiceInterface

Public Member Functions

 SharedMemoryService (const std::shared_ptr< SharedMemorySegmentManager > &sharedMemorySegmentManager, std::shared_ptr< SchedulerService > schedulerService, const std::shared_ptr< ProcessName > &processName)
 
 ~SharedMemoryService () override=default
 
void onInitialize () override
 
std::size_t getGeneration () const
 
void growOf (const std::shared_ptr< SharedMemorySegment > &segment, std::size_t grow) override
 
void shrinkOf (const std::shared_ptr< SharedMemorySegment > &segment) override
 
SharedMemorySegmentInfo showStateOf (const std::shared_ptr< SharedMemorySegment > &segment) const override
 
std::map< std::string, std::shared_ptr< SharedMemorySegmentHandle > > & segmentsOf ()
 
std::mutex & segmentsMutexOf ()
 
SharedMemorySegmentHandle & segmentOf (const std::string &name)
 
ShmSegmentAccessor getSegmentAccessor (const std::shared_ptr< SharedMemorySegment > &segment)
 
- Public Member Functions inherited from lintel::AbstractService< T >
 AbstractService ()=delete
 
 AbstractService (std::string processName, std::string instanceName)
 
 AbstractService (std::string processName)
 
void onShutdown () override
 
ShutdownPriority shutdownPriorityOf () const override
 
const std::string & getProcessName () const override
 
const std::string & getInstanceName () const override
 
std::string_view getClassName () const override
 
- Public Member Functions inherited from lintel::AbstractServiceInterface
virtual ~AbstractServiceInterface ()=default
 
- Public Member Functions inherited from lintel::ISharedMemoryService
virtual ~ISharedMemoryService ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from lintel::PropertyRegistration< SharedMemoryService >
std::shared_ptr< Property< type > > registerProperty (std::string name, type defaultValue, std::string description, bool runtime, const std::string &fileName, int32_t position)
 
- Protected Attributes inherited from lintel::AbstractService< T >
std::vector< std::shared_ptr< PropertyBase > > m_properties
 

Detailed Description

Service for managing shared memory segments and constructing data structures within them.

The service itself is boost free: everything that needs the boost interprocess types lives in ShmConstructors.h (free functions taking the service as first argument) and in ShmSegmentAccessor.h.

Constructor & Destructor Documentation

◆ SharedMemoryService()

lintel::SharedMemoryService::SharedMemoryService ( const std::shared_ptr< SharedMemorySegmentManager > &  sharedMemorySegmentManager,
std::shared_ptr< SchedulerService >  schedulerService,
const std::shared_ptr< ProcessName > &  processName 
)

Construct a SharedMemoryService.

Parameters
sharedMemorySegmentManagerthe segment manager providing segment definitions
schedulerServicethe scheduler for periodic maintenance tasks
processNamethe process name

◆ ~SharedMemoryService()

lintel::SharedMemoryService::~SharedMemoryService ( )
overridedefault

Member Function Documentation

◆ getGeneration()

std::size_t lintel::SharedMemoryService::getGeneration ( ) const

Generation counter incremented on every grow/shrink. Repositories use it to detect that a segment was remapped and re-fetch their references.

Returns
the current generation

◆ getSegmentAccessor()

ShmSegmentAccessor lintel::SharedMemoryService::getSegmentAccessor ( const std::shared_ptr< SharedMemorySegment > &  segment)

Get an accessor to allocate from the given shared memory segment. The returned accessor is a value type and stays valid as long as the segment is mapped by this service.

Parameters
segmentthe shared memory segment
Returns
accessor of the segment
Exceptions
ShmSegmentNotFoundif the segment does not exist

◆ growOf()

void lintel::SharedMemoryService::growOf ( const std::shared_ptr< SharedMemorySegment > &  segment,
std::size_t  grow 
)
overridevirtual

grows the size of the mentioned shared memory block

Implements lintel::ISharedMemoryService.

◆ onInitialize()

void lintel::SharedMemoryService::onInitialize ( )
overridevirtual

Initialize all shared memory segments by opening or creating them.

Reimplemented from lintel::AbstractService< T >.

◆ segmentOf()

SharedMemorySegmentHandle & lintel::SharedMemoryService::segmentOf ( const std::string &  name)

Get the allocated state of the named shared memory segment. Internal: the caller has to hold segmentsMutexOf().

Parameters
namethe name of the segment
Returns
the segment handle
Exceptions
ShmSegmentNotFoundif the segment does not exist

◆ segmentsMutexOf()

std::mutex & lintel::SharedMemoryService::segmentsMutexOf ( )
inline
Returns
the mutex guarding the segment map. Internal: used by the shm construct helpers of ShmConstructors.h, which take the lock before calling segmentOf.

◆ segmentsOf()

std::map< std::string, std::shared_ptr< SharedMemorySegmentHandle > > & lintel::SharedMemoryService::segmentsOf ( )
inline
Returns
the raw segment map. Internal: used by the shm construct helpers of ShmConstructors.h.

◆ showStateOf()

SharedMemorySegmentInfo lintel::SharedMemoryService::showStateOf ( const std::shared_ptr< SharedMemorySegment > &  segment) const
overridevirtual

shows state of the mentioned shared memory segment

Parameters
segment
Returns
string with the printed information

Implements lintel::ISharedMemoryService.

◆ shrinkOf()

void lintel::SharedMemoryService::shrinkOf ( const std::shared_ptr< SharedMemorySegment > &  segment)
overridevirtual

shrinks the shared memory size to the minimum

Implements lintel::ISharedMemoryService.


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