UCommon
Public Member Functions | Protected Member Functions
ucommon::mapped_array< T > Class Template Reference

Map a reusable allocator over a named shared memory segment. More...

#include <mapped.h>

Inherits MappedMemory.

Public Member Functions

void * addLock (void)
 Add mapped space while holding lock for one object. More...
 
void initialize (void)
 Initialize typed data in mapped array. More...
 
 mapped_array (const char *name, unsigned number)
 Construct mapped vector array of typed objects. More...
 
unsigned max (void) const
 Get member size of typed objects that can be held in mapped vector. More...
 
T * operator() (unsigned member)
 Get typed pointer to member object of vector in mapped segment. More...
 
T * operator() (void)
 Allocate mapped space for one object. More...
 
T & operator[] (unsigned member)
 Reference typed object of vector in mapped segment. More...
 

Protected Member Functions

void create (const char *fn, unsigned members)
 

Detailed Description

template<class T>
class ucommon::mapped_array< T >

Map a reusable allocator over a named shared memory segment.

This may be used to form a resource bound fixed size managed heap in shared memory. The request can either be fulfilled from the object reuse pool or from a new section of memory, and if all memory in the segment has been exhausted, it can wait until more objects are returned by another thread to the reuse pool.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org Template class to map typed vector into shared memory. This is used to construct a typed read/write vector of objects that are held in a named shared memory segment.
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 271 of file mapped.h.

Constructor & Destructor Documentation

◆ mapped_array() [1/2]

template<class T >
ucommon::mapped_array< T >::mapped_array ( )
inlineprotected

Definition at line 277 of file mapped.h.

◆ mapped_array() [2/2]

template<class T >
ucommon::mapped_array< T >::mapped_array ( const char *  name,
unsigned  number 
)
inline

Construct mapped vector array of typed objects.

This is constructed for read/write access. mapped_view is used in all cases for read-only access to mapped data. Member objects are linearly allocated from the shared memory segment, or may simply be directly accessed by offset.

Parameters
nameof mapped segment to construct.
numberof objects in the mapped vector.

Definition at line 291 of file mapped.h.

Member Function Documentation

◆ addLock()

template<class T >
void * ucommon::mapped_array< T >::addLock ( void  )
inline

Add mapped space while holding lock for one object.

Returns
address of object.

Definition at line 305 of file mapped.h.

◆ create()

template<class T >
void ucommon::mapped_array< T >::create ( const char *  fn,
unsigned  members 
)
inlineprotected

Definition at line 279 of file mapped.h.

◆ initialize()

template<class T >
void ucommon::mapped_array< T >::initialize ( void  )
inline

Initialize typed data in mapped array.

Assumes default constructor for type.

Definition at line 298 of file mapped.h.

◆ max()

template<class T >
unsigned ucommon::mapped_array< T >::max ( void  ) const
inline

Get member size of typed objects that can be held in mapped vector.

Returns
members mapped in segment.

Definition at line 335 of file mapped.h.

◆ operator()() [1/2]

template<class T >
T * ucommon::mapped_array< T >::operator() ( unsigned  member)
inline

Get typed pointer to member object of vector in mapped segment.

Parameters
memberto access.
Returns
typed pointer or NULL if past end of array.

Definition at line 313 of file mapped.h.

◆ operator()() [2/2]

template<class T >
T * ucommon::mapped_array< T >::operator() ( void  )
inline

Allocate mapped space for one object.

Returns
address of object.

Definition at line 320 of file mapped.h.

◆ operator[]()

template<class T >
T & ucommon::mapped_array< T >::operator[] ( unsigned  member)
inline

Reference typed object of vector in mapped segment.

Parameters
memberto access.
Returns
typed reference.

Definition at line 328 of file mapped.h.

Here is the call graph for this function:

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