25#include <flow/util/util.hpp>
26#include <boost/interprocess/managed_external_buffer.hpp>
27#include <boost/interprocess/detail/managed_open_or_create_impl.hpp>
28#include <boost/noncopyable.hpp>
161template<
typename Mem_algo,
template<
typename>
class Index>
163 private boost::noncopyable
179 using Segment = bipc::basic_managed_external_buffer<char, Mem_algo, Index>;
199 Segment_manager::memory_algorithm::Alignment);
226 using Region = bipc::ipcdetail::managed_open_or_create_impl<Sparse_shm_object, S_SEGMENT_ALIGNMENT, true, true>;
384 bool operator()(
void* addr,
size_t sz,
bool created)
const;
418template<
typename Mem_algo,
template<
typename>
class Index>
430 m_segment(util::
OPEN_ONLY, m_region.get_user_address(), m_region.get_user_size())
435template<
typename Mem_algo,
template<
typename>
class Index>
442 m_region(util::
OPEN_ONLY, pool_name.native_str(), read_only ? bipc::read_only : bipc::read_write, nullptr,
445 m_segment(util::
OPEN_ONLY, m_region.get_user_address(), m_region.get_user_size())
450template<
typename Mem_algo,
template<
typename>
class Index>
459 m_segment(util::
OPEN_ONLY, m_region.get_user_address(), m_region.get_user_size())
464template<
typename Mem_algo,
template<
typename>
class Index>
467 return Segment_manager::get_min_size();
471template<
typename Mem_algo,
template<
typename>
class Index>
479 assert((
reinterpret_cast<uintptr_t
>(addr) %
alignof(
Segment_manager)) == 0);
500template<
typename Mem_algo,
template<
typename>
class Index>
506template<
typename Mem_algo,
template<
typename>
class Index>
512template<
typename Mem_algo,
template<
typename>
class Index>
515 return m_region.get_mapped_region().get_address();
518template<
typename Mem_algo,
template<
typename>
class Index>
524template<
typename Mem_algo,
template<
typename>
class Index>
530 if (shm_object.get_mapping_handle().handle == -1)
540template<
typename Mem_algo,
template<
typename>
class Index>
547 assert((shm_object.get_mapping_handle().handle == -1) &&
"commit() check relies on this.");
Similar to bipc's basic_managed_shared_memory, except that if a ctor created the SHM-pool in the file...
static constexpr size_t S_SEGMENT_OFFSET
Offset from pool-base at which Segment_manager is placed.
Sparse_managed_shm(util::Create_only mode_tag, const Shared_name &pool_name, size_t pool_sz, const util::Permissions &perms={})
Equivalent of the create-only basic_managed_shared_memory ctor.
Segment * core()
Access to the (mutating) managed-memory API.
Region m_region
See Region.
static constexpr size_t S_SEGMENT_ALIGNMENT
Alignment of Segment_manager placement: the stricter of: whatever it itself needs; mem-algo's configu...
void * address() const
Equivalent of basic_managed_shared_memory::get_address(), this equals core()->get_address() minus S_S...
typename Segment::segment_manager Segment_manager
Short-hand for Segment::segment_manager.
bipc::ipcdetail::managed_open_or_create_impl< Sparse_shm_object, S_SEGMENT_ALIGNMENT, true, true > Region
bipc's startup engine behind its basic_managed_shared_memory, parameterized in such a way as to suppo...
size_t size() const
Equivalent of basic_managed_shared_memory::get_size(), this equals core()->get_size() plus S_SEGMENT_...
bipc::basic_managed_external_buffer< char, Mem_algo, Index > Segment
The type through which (and through method core() which returns one of these) one accesses the main m...
bool commit()
Commit (take RAM for) every page of the SHM-pool: forwards to Sparse_shm_object::commit() and returns...
void close_shm_object_handle()
Close the SHM-pool handle, if any is still open, returning that resource to the system (while a *this...
Segment m_segment
Stores the handle to the Segment_manager inside the mapped vaddr extent, it is accessed via core().
Similar to bipc's shared_memory_object, but truncate() will not unconditionally commit the entire spe...
void commit()
Commit (take RAM for) every page of the SHM-object's size as determined by the last truncate().
String-wrapping abstraction representing a name uniquely distinguishing a kernel-persistent entity fr...
Extensions, informal or otherwise, of boost.ipc (boost::interprocess, bipc) SHM-related facilities,...
bipc::permissions Permissions
Short-hand for Unix (POSIX) permissions class.
bipc::open_only_t Open_only
Tag type indicating an ideally-atomic open-if-exists-else-fail operation.
const Open_or_create OPEN_OR_CREATE
Tag value indicating an open-if-exists-else-create operation.
const Open_only OPEN_ONLY
Tag value indicating an atomic open-if-exists-else-fail operation.
bipc::open_or_create_t Open_or_create
Tag type indicating an atomic open-if-exists-else-create operation.
bipc::create_only_t Create_only
Tag type indicating a create-unless-exists-else-fail operation.
const Create_only CREATE_ONLY
Tag value indicating an atomic create-unless-exists-else-fail operation.
What Region invokes, inside its create-vs-open handshake, once the pool is mapped.
static size_t get_min_size()
Required by Region: returns Segment_manager::get_min_size().
bool operator()(void *addr, size_t sz, bool created) const
The functor action as required/invoked by Region in its ctor.