29#include <flow/util/util.hpp>
102template<
typename Shm_arena_t>
182template<
typename Shm_arena_t>
186 m_shm_arena(std::move(shm_arena)),
187 m_lend_tracker_pool_id(lend_tracker_pool_id),
188 m_use_ct_idx(use_ct_idx),
189 m_cting_thread_token(flow::util::this_thread_unique_token())
194template<
typename Shm_arena_t>
200 if (flow::util::this_thread_unique_token() == m_cting_thread_token)
233template<
typename T,
typename Shm_session>
239 std::shared_ptr<const Shm_session>&& shm_session_to_keep_alive)
243 return Obj_handle<T>(addr, [lend_tracker_pool_id, use_ct_idx, owner_id, collection_id,
244 shm_session_to_keep_alive = std::move(shm_session_to_keep_alive)]
251 owner_id, collection_id);
259 shm_session_to_keep_alive.reset();
static Thread_lcl_obj_db_admin * this_thread_obj_db()
Returns the calling thread's Thread_lcl_obj_db_admin, creating it on first call from that thread.
void disposing_obj(collection_id_t collection_id, use_ct_idx_t use_ct_idx)
Records disposal of a handle to a constructed object (as of this writing: shared_ptr group reaching r...
static void this_thread_piggy_scan()
If the calling thread has a Thread_lcl_obj_db_admin (i.e., this_thread_obj_db() has been called at le...
void disposing_obj(const Shm_arena &shm_arena, pool_id_t lend_tracker_pool_id, use_ct_idx_t use_ct_idx)
Client-side (owner process, non-constructing thread) counterpart to Thread_lcl_obj_db_admin::disposin...
static Thread_lcl_obj_db_client * this_thread_obj_db()
Identical to Thread_lcl_obj_db_admin::this_thread_obj_db() but for the client-side DB.
Segregated private stuff for ipc::shm::arena_lend.
uint32_t pool_id_t
Pool ID type.
Obj_handle< T > construct_with_borrower_obj_disposer(T *addr, pool_id_t lend_tracker_pool_id, use_ct_idx_t use_ct_idx, owner_id_t owner_id, collection_id_t collection_id, std::shared_ptr< const Shm_session > &&shm_session_to_keep_alive)
(Roughly) the borrower-side counterpart of Owner_obj_disposer_and_mdt, this returns a borrower-side h...
uint32_t use_ct_idx_t
Index into a given Lend_tracker_pool's bulk storage of arena-construct()ed (outer a/k/a first-class) ...
uint32_t collection_id_t
Identifier type for a shared memory pool collection.
std::shared_ptr< T > Obj_handle
Determines the shared_ptr variety returned by A::construct() and S::borrow_object() for any arena-len...
util::process_id_t owner_id_t
Alias for an identifier of the owner (essentially namespace of collection_id_ts) of shared informatio...
Internal-use shared_ptr disposer object, attached to every cross-process-lendable object handle retur...
Owner_obj_disposer_and_mdt(Shm_arena_ptr &&shm_arena, pool_id_t lend_tracker_pool_id, use_ct_idx_t use_ct_idx)
Constructs disposer, memorizing the args – including saving a ref-counted ref to the Shm_arena so as ...
const pool_id_t m_lend_tracker_pool_id
ID of aux (use-count-tracking) SHM-pool, as output by Thread_lcl_obj_db_admin::constructing_obj().
const use_ct_idx_t m_use_ct_idx
The use-count slot within pool identified by m_lend_tracker_pool_id, as output by the same obj-DB-adm...
Shm_arena_ptr m_shm_arena
Ref-cted handle to the Shm_arena that ->construct<T>()ed, creating us as part of that.
Shm_arena_t Shm_arena
Alias for template parameter.
std::shared_ptr< Shm_arena > Shm_arena_ptr
Short-hand for ref-counted handle to Shm_arena.
void operator()(T *addr)
The disposer function that runs at most once: when the linked shared_ptr group's ref-count reaches ze...
const flow::util::Thread_token m_cting_thread_token
The thread-token (flow::util::this_thread_unique_token()) of the thread that Shm_arena::construct()ed...