JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
observe_pool.h File Reference

Top-level user-facing pool for content-based interning of immutable objects. More...

#include <concepts>
#include <cstdint>
#include <utility>
#include "jh/concurrent/pointer_pool.h"
#include "jh/conceptual/hashable.h"

Go to the source code of this file.

Classes

struct  jh::weak_ptr_hash< T >
 Content-based hash functor for std::weak_ptr<T>. More...
struct  jh::weak_ptr_eq< T >
 Equality functor for std::weak_ptr<T>. More...

Typedefs

template<typename T>
using jh::observe_pool
 Duck-typed alias of jh::conc::pointer_pool for content-based pooling of immutable objects.

Detailed Description

Top-level user-facing pool for content-based interning of immutable objects.

Author
JeongHan-Bae <mastropseudo@gmail.com>

jh::observe_pool<T> is a duck-typed, user-oriented pooling facility built on top of jh::conc::pointer_pool. It provides content-based deduplication for immutable or structurally immutable objects, without requiring explicit hash or equality policy specification.

The pool observes object lifetimes via std::weak_ptr and never owns pooled objects. Logical identity is defined by T's hashing semantics and operator==.

observe_pool is defined as a direct alias of jh::conc::pointer_pool with automatically selected jh::weak_ptr_hash<T> and jh::weak_ptr_eq<T>. Instantiation is valid only when the underlying type requirements are satisfied.

As a user-facing pool under the jh namespace, it is available via:

  • <jh/pool>
  • <jh/concurrency>
Version
1.4.x
Date
2025