Description

This object is placed in the beginning of memory segment and implements the allocation (named or anonymous) of portions of the segment. This object contains two indexes that maintain an association between a name and a portion of the segment.

The first index contains the mappings for normal named objects using the char type specified in the template parameter.

The second index contains the association for unique instances. The key will be the const char * returned from type_info.name() function for the unique type to be constructed.

segment_manager<CharType, MemoryAlgorithm, IndexType> inherits publicly from segment_manager_base<MemoryAlgorithm> and inherits from it many public functions related to anonymous object and raw memory allocation. See segment_manager_base reference to know about those functions.

segment_manager
public
construct/copy/destruct

segment_manager(size_type size);

Constructor of the segment manager "size" is the size of the memory segment where the segment manager is being constructed. Can throw

segment_manager public member functions

template<typename T>std::pair<T*,size_type>find(constCharType* name);

Tries to find a previous named allocation. Returns the address and the object count. On failure the first member of the returned pair is 0.

template<typename T>std::pair<T*,size_type>find(unspecified name);

Tries to find a previous unique allocation. Returns the address and the object count. On failure the first member of the returned pair is 0.

Calls object function blocking recursive interprocess_mutex and guarantees that no new named_alloc or destroy will be executed by any process while executing the object function call

template<typename Func>booltry_atomic_func(Func& f);

Tries to calls a functor guaranteeing that no new construction, search or destruction will be executed by any process while executing the object function call. If the atomic function can't be immediatelly executed because the internal mutex is already locked, returns false. If the functor throws, this function throws.

template<typename T>booldestroy(unspecified);

Destroys a previously created unique instance. Returns false if the object was not present.

template<typename T>booldestroy(constCharType* name);

Destroys the named object with the given name. Returns false if that object can't be found.

template<typename T>voiddestroy_ptr(constT* p);

Destroys an anonymous, unique or named object using it's address

voidreserve_named_objects(size_type num);

Preallocates needed index resources to optimize the creation of "num" named objects in the managed memory segment. Can throw boost::interprocess::bad_alloc if there is no enough memory.

voidreserve_unique_objects(size_type num);

Preallocates needed index resources to optimize the creation of "num" unique objects in the managed memory segment. Can throw boost::interprocess::bad_alloc if there is no enough memory.

voidshrink_to_fit_indexes();

Calls shrink_to_fit in both named and unique object indexes to try to free unused memory from those indexes.

size_typeget_num_named_objects();

Returns the number of named objects stored in the segment.

size_typeget_num_unique_objects();

Returns the number of unique objects stored in the segment.

const_named_iteratornamed_begin()const;

Returns a constant iterator to the beginning of the information about the named allocations performed in this segment manager

const_named_iteratornamed_end()const;

Returns a constant iterator to the end of the information about the named allocations performed in this segment manager

const_unique_iteratorunique_begin()const;

Returns a constant iterator to the beginning of the information about the unique allocations performed in this segment manager

const_unique_iteratorunique_end()const;

Returns a constant iterator to the end of the information about the unique allocations performed in this segment manager