This object is placed in the beginning of memory segment and implements the allocation (named or anonymous) of portions of the segment. More...
#include <segment_manager.hpp>
Classes | |
struct | allocator |
This is the default allocator to allocate types T from this managed segment. More... | |
struct | construct_iter_proxy |
Constructor proxy object definition helper class. More... | |
struct | construct_proxy |
Constructor proxy object definition helper class. More... | |
struct | deleter |
This is the default deleter to delete types T from this managed segment. More... | |
Public Types | |
typedef MemoryAlgorithm | memory_algorithm |
typedef segment_manager_base_t::void_pointer | void_pointer |
typedef segment_manager_base_t::size_type | size_type |
typedef segment_manager_base_t::difference_type | difference_type |
typedef CharType | char_type |
typedef segment_manager_base < MemoryAlgorithm > | segment_manager_base_type |
typedef IndexType < index_config_named > | named_index_t |
typedef IndexType < index_config_unique > | unique_index_t |
typedef ipcdetail::char_ptr_holder < CharType > | char_ptr_holder_t |
typedef ipcdetail::segment_manager_iterator_transform < typename named_index_t::const_iterator,is_intrusive_index < index_type >::value > | named_transform |
typedef ipcdetail::segment_manager_iterator_transform < typename unique_index_t::const_iterator,is_intrusive_index < index_type >::value > | unique_transform |
typedef segment_manager_base_t::mutex_family | mutex_family |
typedef transform_iterator < typename named_index_t::const_iterator, named_transform > | const_named_iterator |
typedef transform_iterator < typename unique_index_t::const_iterator, unique_transform > | const_unique_iterator |
typedef MemoryAlgorithm::multiallocation_chain | multiallocation_chain |
Public Member Functions | |
segment_manager (size_type segment_size) | |
Constructor of the segment manager "size" is the size of the memory segment where the segment manager is being constructed. More... | |
template<class T > | |
std::pair< T *, size_type > | find (char_ptr_holder_t name) |
Tries to find a previous named/unique allocation. More... | |
template<class T > | |
std::pair< T *, size_type > | find_no_lock (char_ptr_holder_t name) |
Tries to find a previous named/unique allocation. More... | |
template<class T > | |
construct_proxy< T >::type | construct (char_ptr_holder_t name) |
Returns throwing "construct" proxy object. More... | |
template<class T > | |
construct_proxy< T >::type | find_or_construct (char_ptr_holder_t name) |
Returns throwing "search or construct" proxy object. More... | |
template<class T > | |
construct_proxy< T >::type | construct (char_ptr_holder_t name, std::nothrow_t) |
Returns no throwing "construct" proxy object. More... | |
template<class T > | |
construct_proxy< T >::type | find_or_construct (char_ptr_holder_t name, std::nothrow_t) |
Returns no throwing "search or construct" proxy object. More... | |
template<class T > | |
construct_iter_proxy< T >::type | construct_it (char_ptr_holder_t name) |
Returns throwing "construct from iterators" proxy object. More... | |
template<class T > | |
construct_iter_proxy< T >::type | find_or_construct_it (char_ptr_holder_t name) |
Returns throwing "search or construct from iterators" proxy object. More... | |
template<class T > | |
construct_iter_proxy< T >::type | construct_it (char_ptr_holder_t name, std::nothrow_t) |
Returns no throwing "construct from iterators" proxy object. More... | |
template<class T > | |
construct_iter_proxy< T >::type | find_or_construct_it (char_ptr_holder_t name, std::nothrow_t) |
Returns no throwing "search or construct from iterators" proxy object. More... | |
template<class Func > | |
void | atomic_func (Func &f) |
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. More... | |
template<class Func > | |
bool | try_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. More... | |
template<class T > | |
bool | destroy (char_ptr_holder_t name) |
Destroys a previously created named/unique instance. More... | |
template<class T > | |
void | destroy_ptr (const T *p) |
Destroys an anonymous, unique or named object using its address. More... | |
void | reserve_named_objects (size_type num) |
Preallocates needed index resources to optimize the creation of "num" named objects in the managed memory segment. More... | |
void | reserve_unique_objects (size_type num) |
Preallocates needed index resources to optimize the creation of "num" unique objects in the managed memory segment. More... | |
void | shrink_to_fit_indexes () |
Calls shrink_to_fit in both named and unique object indexes to try to free unused memory from those indexes. More... | |
size_type | get_num_named_objects () |
Returns the number of named objects stored in the segment. More... | |
size_type | get_num_unique_objects () |
Returns the number of unique objects stored in the segment. More... | |
const_named_iterator | named_begin () const |
Returns a constant iterator to the beginning of the information about the named allocations performed in this segment manager. More... | |
const_named_iterator | named_end () const |
Returns a constant iterator to the end of the information about the named allocations performed in this segment manager. More... | |
const_unique_iterator | unique_begin () const |
Returns a constant iterator to the beginning of the information about the unique allocations performed in this segment manager. More... | |
const_unique_iterator | unique_end () const |
Returns a constant iterator to the end of the information about the unique allocations performed in this segment manager. More... | |
template<class T > | |
allocator< T >::type | get_allocator () |
Returns an instance of the default allocator for type T initialized that allocates memory from this segment manager. More... | |
template<class T > | |
deleter< T >::type | get_deleter () |
Returns an instance of the default deleter for type T that will delete an object constructed in this segment manager. More... | |
template<class T > | |
T * | generic_construct (const CharType *name, size_type num, bool try2find, bool dothrow, ipcdetail::in_place_interface &table) |
Generic named/anonymous new function. More... | |
size_type | get_size () const |
Returns the size of the memory segment. More... | |
size_type | get_free_memory () const |
Returns the number of free bytes of the memory segment. More... | |
void * | allocate (size_type nbytes, std::nothrow_t) |
Allocates nbytes bytes. More... | |
void * | allocate (size_type nbytes) |
Allocates nbytes bytes. More... | |
void | allocate_many (size_type elem_bytes, size_type n_elements, multiallocation_chain &chain) |
Allocates n_elements of elem_bytes bytes. More... | |
void | allocate_many (const size_type *element_lengths, size_type n_elements, size_type sizeof_element, multiallocation_chain &chain) |
Allocates n_elements, each one of element_lengths[i]*sizeof_element bytes. More... | |
void | allocate_many (std::nothrow_t, size_type elem_bytes, size_type n_elements, multiallocation_chain &chain) |
Allocates n_elements of elem_bytes bytes. More... | |
void | allocate_many (std::nothrow_t, const size_type *elem_sizes, size_type n_elements, size_type sizeof_element, multiallocation_chain &chain) |
Allocates n_elements, each one of element_lengths[i]*sizeof_element bytes. More... | |
void | deallocate_many (multiallocation_chain &chain) |
Deallocates all elements contained in chain. More... | |
void * | allocate_aligned (size_type nbytes, size_type alignment, std::nothrow_t) |
Allocates nbytes bytes. More... | |
void * | allocate_aligned (size_type nbytes, size_type alignment) |
Allocates nbytes bytes. More... | |
template<class T > | |
std::pair< T *, bool > | allocation_command (boost::interprocess::allocation_type command, size_type limit_size, size_type preferred_size, size_type &received_size, T *reuse_ptr=0) |
std::pair< void *, bool > | raw_allocation_command (boost::interprocess::allocation_type command, size_type limit_objects, size_type preferred_objects, size_type &received_objects, void *reuse_ptr=0, size_type sizeof_object=1) |
void | deallocate (void *addr) |
Deallocates the bytes allocated with allocate/allocate_many() pointed by addr. More... | |
void | grow (size_type extra_size) |
Increases managed memory in extra_size bytes more. More... | |
void | shrink_to_fit () |
Decreases managed memory to the minimum. More... | |
bool | all_memory_deallocated () |
Returns the result of "all_memory_deallocated()" function of the used memory algorithm. More... | |
bool | check_sanity () |
Returns the result of "check_sanity()" function of the used memory algorithm. More... | |
void | zero_free_memory () |
Writes to zero free memory (memory not yet allocated) of the memory algorithm. More... | |
size_type | size (const void *ptr) const |
Returns the size of the buffer previously allocated pointed by ptr. More... | |
Static Public Member Functions | |
template<class T > | |
static const CharType * | get_instance_name (const T *ptr) |
Returns the name of an object created with construct/find_or_construct functions. More... | |
template<class T > | |
static size_type | get_instance_length (const T *ptr) |
Returns the length of an object created with construct/find_or_construct functions. More... | |
template<class T > | |
static instance_type | get_instance_type (const T *ptr) |
Returns is the the name of an object created with construct/find_or_construct functions. More... | |
static size_type | get_min_size () |
Obtains the minimum size needed by the segment manager. More... | |
static size_type | get_min_size (size_type size) |
Obtains the minimum size needed by the segment manager. More... | |
Static Public Attributes | |
static const size_type | PayloadPerAllocation = segment_manager_base_t::PayloadPerAllocation |
Protected Member Functions | |
void * | prot_anonymous_construct (size_type num, bool dothrow, ipcdetail::in_place_interface &table) |
void | prot_anonymous_destroy (const void *object, ipcdetail::in_place_interface &table) |
Calls the destructor and makes an anonymous deallocate. More... | |
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.
typedef ipcdetail::char_ptr_holder<CharType> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::char_ptr_holder_t |
typedef CharType boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::char_type |
typedef transform_iterator<typename named_index_t::const_iterator, named_transform> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::const_named_iterator |
typedef transform_iterator<typename unique_index_t::const_iterator, unique_transform> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::const_unique_iterator |
typedef segment_manager_base_t::difference_type boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::difference_type |
typedef MemoryAlgorithm boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::memory_algorithm |
|
inherited |
typedef segment_manager_base_t::mutex_family boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::mutex_family |
typedef IndexType<index_config_named> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::named_index_t |
typedef ipcdetail::segment_manager_iterator_transform<typename named_index_t::const_iterator ,is_intrusive_index<index_type>::value> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::named_transform |
typedef segment_manager_base<MemoryAlgorithm> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::segment_manager_base_type |
typedef segment_manager_base_t::size_type boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::size_type |
typedef IndexType<index_config_unique> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::unique_index_t |
typedef ipcdetail::segment_manager_iterator_transform<typename unique_index_t::const_iterator ,is_intrusive_index<index_type>::value> boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::unique_transform |
typedef segment_manager_base_t::void_pointer boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::void_pointer |
|
inlineexplicit |
Constructor of the segment manager "size" is the size of the memory segment where the segment manager is being constructed.
Can throw
References BOOST_ASSERT, and boost::detail::void.
|
inlineinherited |
Returns the result of "all_memory_deallocated()" function of the used memory algorithm.
|
inlineinherited |
Allocates nbytes bytes.
This function is only used in single-segment management. Never throws
Referenced by boost::interprocess::segment_manager_base< MemoryAlgorithm >::prot_anonymous_construct().
|
inlineinherited |
Allocates nbytes bytes.
Throws boost::interprocess::bad_alloc on failure
|
inlineinherited |
Allocates nbytes bytes.
This function is only used in single-segment management. Never throws
|
inlineinherited |
Allocates nbytes bytes.
This function is only used in single-segment management. Throws bad_alloc when fails
|
inlineinherited |
Allocates n_elements of elem_bytes bytes.
Throws bad_alloc on failure. chain.size() is not increased on failure.
|
inlineinherited |
Allocates n_elements, each one of element_lengths[i]*sizeof_element bytes.
Throws bad_alloc on failure. chain.size() is not increased on failure.
|
inlineinherited |
Allocates n_elements of elem_bytes bytes.
Non-throwing version. chain.size() is not increased on failure.
|
inlineinherited |
Allocates n_elements, each one of element_lengths[i]*sizeof_element bytes.
Non-throwing version. chain.size() is not increased on failure.
|
inlineinherited |
|
inline |
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.
|
inlineinherited |
Returns the result of "check_sanity()" function of the used memory algorithm.
|
inline |
Returns throwing "construct" proxy object.
|
inline |
Returns no throwing "construct" proxy object.
|
inline |
Returns throwing "construct from iterators" proxy object.
|
inline |
Returns no throwing "construct from iterators" proxy object.
|
inlineinherited |
Deallocates the bytes allocated with allocate/allocate_many() pointed by addr.
Referenced by boost::interprocess::segment_manager_base< MemoryAlgorithm >::prot_anonymous_destroy().
|
inlineinherited |
Deallocates all elements contained in chain.
Never throws.
|
inline |
Destroys a previously created named/unique instance.
Returns false if the object was not present.
References BOOST_ASSERT, boost::iostreams::gzip::flags::name, and T.
|
inline |
Destroys an anonymous, unique or named object using its address.
References boost::detail::type.
|
inline |
Tries to find a previous named/unique allocation.
Returns the address and the object count. On failure the first member of the returned pair is 0.
References boost::iostreams::gzip::flags::name.
|
inline |
Tries to find a previous named/unique allocation.
Returns the address and the object count. On failure the first member of the returned pair is 0. This search is not mutex-protected! Use it only inside atomic_func() calls, where the internal mutex is guaranteed to be locked.
References boost::iostreams::gzip::flags::name.
|
inline |
Returns throwing "search or construct" proxy object.
|
inline |
Returns no throwing "search or construct" proxy object.
|
inline |
Returns throwing "search or construct from iterators" proxy object.
|
inline |
Returns no throwing "search or construct from iterators" proxy object.
|
inline |
Generic named/anonymous new function.
Offers all the possibilities, such as throwing, search before creating, and the constructor is encapsulated in an object function.
References T.
|
inline |
Returns an instance of the default allocator for type T initialized that allocates memory from this segment manager.
|
inline |
Returns an instance of the default deleter for type T that will delete an object constructed in this segment manager.
|
inlineinherited |
Returns the number of free bytes of the memory segment.
|
inlinestatic |
Returns the length of an object created with construct/find_or_construct functions.
Does not throw.
References T.
|
inlinestatic |
Returns the name of an object created with construct/find_or_construct functions.
Does not throw
|
inlinestatic |
Returns is the the name of an object created with construct/find_or_construct functions.
Does not throw
|
inlinestaticinherited |
Obtains the minimum size needed by the segment manager.
Referenced by boost::interprocess::segment_manager< CharType, MemoryAlgorithm, IndexType >::get_min_size().
|
inlinestatic |
Obtains the minimum size needed by the segment manager.
References boost::interprocess::segment_manager_base< MemoryAlgorithm >::get_min_size().
|
inline |
Returns the number of named objects stored in the segment.
|
inline |
Returns the number of unique objects stored in the segment.
|
inlineinherited |
Returns the size of the memory segment.
|
inlineinherited |
Increases managed memory in extra_size bytes more.
This only works with single-segment management.
|
inline |
Returns a constant iterator to the beginning of the information about the named allocations performed in this segment manager.
References boost::iterators::make_transform_iterator().
|
inline |
Returns a constant iterator to the end of the information about the named allocations performed in this segment manager.
References boost::iterators::make_transform_iterator().
|
inlineprotectedinherited |
|
inlineprotectedinherited |
Calls the destructor and makes an anonymous deallocate.
References BOOST_ASSERT, and boost::interprocess::segment_manager_base< MemoryAlgorithm >::deallocate().
|
inlineinherited |
|
inline |
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.
|
inline |
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.
|
inlineinherited |
Decreases managed memory to the minimum.
This only works with single-segment management.
|
inline |
Calls shrink_to_fit in both named and unique object indexes to try to free unused memory from those indexes.
|
inlineinherited |
Returns the size of the buffer previously allocated pointed by ptr.
References boost::fusion::size().
|
inline |
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.
References boost::try_to_lock.
|
inline |
Returns a constant iterator to the beginning of the information about the unique allocations performed in this segment manager.
References boost::iterators::make_transform_iterator().
|
inline |
Returns a constant iterator to the end of the information about the unique allocations performed in this segment manager.
References boost::iterators::make_transform_iterator().
|
inlineinherited |
Writes to zero free memory (memory not yet allocated) of the memory algorithm.
|
static |