32#include <flow/util/util.hpp>
33#include <boost/interprocess/sync/mutex_family.hpp>
34#include <boost/interprocess/offset_ptr.hpp>
35#include <boost/array.hpp>
156 private boost::noncopyable
226 static constexpr size_t S_ALIGN_SZ = flow::util::max_align_sz();
291 static constexpr size_t get_min_size(
size_t extra_hdr_sz);
385 void grow(
size_t extra_sz);
408 template<
typename Metadata>
522 "Come on now... PAGE_SZ should be a multiple of the most stringent alignment (16 or w/e).");
527 "Please set USE_COUNTS_CAPACITYxALLOC_SZ to a positive multiple of PAGE_SZ; "
528 "and set USE_COUNTS_CAPACITY to be a multiple of 8 (bits/byte).");
536 "Please set USE_COUNTS_CAPACITY to a multiple of [8 (bits/byte) x bit_word_t (8)].");
539 "Please set USE_COUNTS_CAPACITY_QUANTUM_SZ to USE_COUNTS_CAPACITY divided by some integer.");
541 "Please set USE_COUNTS_CAPACITY_QUANTUM_SZ to a positive multiple of 8 (bits/byte).");
547 "Please set USE_COUNTS_CAPACITY_QUANTUM_SZ to a multiple of [8 (bits/byte) x bit_word_t (8)].");
658 using flow::util::round_to_multiple;
686 + round_to_multiple(extra_hdr_sz,
S_ALIGN_SZ),
703template<
typename Metadata>
A boost.ipc-compliant memory-algorithm suitable for use in a bipc_ext::Sparse_managed_shm (which is a...
static constexpr size_t Alignment
boost.ipc expects this stylization of S_ALIGN_SZ.
static constexpr size_t get_min_size(size_t extra_hdr_sz)
Size we require at max capacity (all S_USE_COUNTS_CAPACITY times S_ALLOC_SZ bytes used) for the conta...
size_t get_free_memory() const
How many allocate(N) calls, times S_ALLOC_SZ, would succeed now without deallocate() in-between,...
void grow(size_t extra_sz)
No-op: as of this writing a *this will allocate up to S_USE_COUNTS_CAPACITY times S_ALLOC_SZ,...
static constexpr size_t base_offset()
The number of bytes between the start of the SHM-pool (segment) storing us and us (*this).
static constexpr size_t S_BITMAP_QUANTUM_SZ
The size of each bitmap section (in bytes) corresponding to 1 quantum of use-count slots (each N byte...
static constexpr size_t S_USE_COUNTS_CAPACITY_QUANTUM_SZ
The size of each quantum into a whole number of which the data area (sized S_USE_COUNTS_CAPACITY N-by...
Header m_header
See Header doc header.
static constexpr size_t S_ALLOC_SZ
This important constant defines the mandatory size of each allocation – that is argument to allocate(...
void deallocate(void *addr) noexcept
Reverses an earlier allocate() call.
::ipc::bipc::offset_ptr< void > Void_pointer
This alias is required for use in a basic_managed_shared_memory; offset_ptr is a solid default choice...
static constexpr size_t PayloadPerAllocation
boost.ipc segment_manager requires this of a memory-algorithm: per-allocation book-keeping overhead i...
Metadata * get_metadata()
Convenience function that returns the metadata area as a properly-typed pointer.
size_t stats_record_at_deletion(Obj_db_aux_pool_stats *target_stats)
Assuming one has followed the required algorithm to update *target_stats so far, this method (intende...
static constexpr size_t S_ALIGN_SZ
The most stringent alignment. E.g., in x86-64 this is 16, we've observed.
::ipc::bipc::null_mutex_family Mutex_family
This indicates that when using this as the memory-algorithm, we shall use no locking; this is a key a...
size_t stats_record(size_t prev_quanta_active, Obj_db_aux_pool_stats *target_stats)
Updates the various GAUGEs and HI_WMARKs in *target_stats, if and only if it is appropriate to do so ...
uint64_t bit_word_t
In the bitmap mapping the data area of size S_USE_COUNTS_CAPACITY, this defines a word of bits; a wor...
static constexpr size_t S_BITMAP_SZ
The total size of the bitmap area which uses 1 bit per 1 use-count slot (each N bytes wide) of the da...
static constexpr size_t S_PAGE_SZ
Default page size.
Mutex_family mutex_family
boost.ipc expects this stylization of Mutex_family.
boost::array< bit_word_t, S_BITMAP_SZ/sizeof(bit_word_t)> Bitmap_words
The raw data of the bitmap: an array of words, each word representing [sizeof(word) x 8] use-count sl...
void * allocate(size_t sz)
Allocates space out of S_USE_COUNTS_CAPACITY times S_ALLOC_SZ bytes available originally,...
ptrdiff_t difference_type
The usual difference_type.
size_t stat_quanta_active() const
Returns a non-negative number that is some compile-time constant K times the number of quanta current...
Use_count_registry(size_t sz, size_t extra_hdr_sz)
Constructs a *this, assumed to be in a SHM-pool (segment) at the time the Sparse_managed_shm is being...
static constexpr size_t S_USE_COUNTS_CAPACITY
Compile-time knob: how many (N-byte) use-counts one *this can allocate.
size_t get_size() const
Returns the value passed to ctor, when the pool was created.
int multiallocation_chain
Possibly required for things to build, but we do not supply an allocate_many(), so we set it to a dum...
Void_pointer void_pointer
boost.ipc expects this stylization of Void_pointer.
static constexpr size_t S_SEGMENT_OFFSET
Offset from pool-base at which Segment_manager is placed.
Segregated private stuff for ipc::shm::arena_lend.
Stats about the RAM use of the arena-lending SHM-provider's auxiliary (non-user-data) SHM-pools which...