|
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.
|
Namespaces | |
| namespace | async |
| Aggregated entry point for coroutine-based asynchronous facilities. | |
| namespace | concepts |
| Behavioral concept namespace of the JH Toolkit. | |
| namespace | ranges |
| Semantic pipeline namespace for JH range operations. | |
| namespace | conc |
| Aggregated namespace for concurrency-aware resource containers. | |
| namespace | avl |
Internal AVL-tree implementation namespace for jh::ordered_set and jh::ordered_map. | |
| namespace | runtime_arr_helper |
Helper utilities and auxiliary types for jh::runtime_arr. | |
| namespace | ipc |
Convenience alias for jh::sync::ipc. | |
| namespace | jindallae |
Symbolic alias namespace for jh::meta. | |
| namespace | macro |
| Internal macro-based utilities. | |
| namespace | meta |
| Aggregated entry point for compile-time metaprogramming utilities. | |
| namespace | pod |
| Aggregated entry point for Plain-Old-Data and layout-stable value utilities. | |
| namespace | typed |
| Aggregated entry point for lightweight typing and semantic placeholder utilities. | |
| namespace | serio |
| Aggregated entry point for serialization and codec utilities. | |
| namespace | sync |
| Aggregated entry point for synchronization and coordination facilities. | |
| namespace | views |
Convenience alias for jh::ranges::views. | |
Classes | |
| struct | container_deduction |
| User customization point for container element deduction. More... | |
| struct | hash |
| Behaviorally deduced hash functor. More... | |
| struct | hash< T, std::enable_if_t< jh::concepts::has_std_hash< T > > > |
| Case 1: std::hash<T> is valid. More... | |
| struct | hash< T, std::enable_if_t<!jh::concepts::has_std_hash< T > &&jh::concepts::has_adl_hash< T > > > |
| Case 2: ADL-discovered hash(T). More... | |
| struct | hash< T, std::enable_if_t<!jh::concepts::has_std_hash< T > &&!jh::concepts::has_adl_hash< T > &&jh::concepts::has_mbr_hash< T > > > |
| Case 3: Member hash(). More... | |
| struct | iterator |
Forward declaration of jh::iterator<Container>. More... | |
| struct | recursive_registry |
| Trait registry for detecting counting reentrance (recursive). More... | |
| struct | reentrant_registry |
| Trait registry for detecting idempotent (structural) reentrance. More... | |
| struct | recursive_registry< std::recursive_mutex > |
Specialization for std::recursive_mutex. More... | |
| struct | recursive_registry< std::recursive_timed_mutex > |
Specialization for std::recursive_timed_mutex. More... | |
| struct | weak_ptr_hash |
Content-based hash functor for std::weak_ptr<T>. More... | |
| struct | weak_ptr_eq |
Equality functor for std::weak_ptr<T>. More... | |
| class | flat_multimap |
| Flat ordered multimap implemented as a sorted contiguous container. More... | |
| class | immutable_str |
| Immutable string with optional automatic trimming and thread-safe hash caching. More... | |
| struct | atomic_str_hash |
Custom hash functor for atomic_str_ptr and compatible types. More... | |
| struct | atomic_str_eq |
Custom equality functor for atomic_str_ptr and compatible types. More... | |
| class | runtime_arr |
| A move-only, fixed-capacity array with runtime-determined length and RAII-based ownership. More... | |
| class | runtime_arr< bool > |
Specialized implementation of jh::runtime_arr<bool> — a compact, bit-packed boolean array. More... | |
| class | generator_range |
| A range-like wrapper that enables iteration over a generator factory. More... | |
Concepts | |
| concept | immutable_str_compatible |
Concept for types compatible with jh::immutable_str. | |
Typedefs | |
| template<typename T> | |
| using | observe_pool |
Duck-typed alias of jh::conc::pointer_pool for content-based pooling of immutable objects. | |
| template<typename Key, typename Value = jh::typed::monostate, typename Alloc = std::allocator<jh::conc::detail::value_t<Key, Value>>> | |
| using | resource_pool = jh::conc::flat_pool<Key, Value, jh::hash<Key>, Alloc> |
Convenience alias of jh::conc::flat_pool with behaviorally deduced hashing. | |
| template<typename Key, typename Alloc = std::allocator<Key>> | |
| using | resource_pool_set = jh::conc::flat_pool<Key, jh::typed::monostate, jh::hash<Key>, Alloc> |
Set-style specialization of jh::resource_pool. | |
| using | atomic_str_ptr = std::shared_ptr<immutable_str> |
| Atomically replaceable handle to an immutable string. | |
| template<typename K, typename Alloc = std::allocator<K>> | |
| using | ordered_set |
| Ordered associative set based on a contiguous-array AVL tree. | |
| template<typename K, typename V, typename Alloc = std::allocator<std::pair<const K, V>>> | |
| using | ordered_map |
| Ordered associative map based on a contiguous-array AVL tree. | |
| template<typename T, typename U = typed::monostate> | |
| using | generator = async::generator<T, U> |
Alias of jh::async::generator in the root namespace. | |
Functions | |
| template<typename F> | |
| auto | to_range (F &&f) |
| Converts a generator factory (lambda or function) into a repeatable range. | |
| template<concepts::sequence Seq> | |
| decltype(auto) | to_range (Seq &&s) |
Converts a sequence into a usable std::ranges::range object. | |
| template<typename T> | |
| atomic_str_ptr | make_atomic (T str)=delete |
| atomic_str_ptr | make_atomic (const char *str) |
Creates a shared pointer to an immutable_str. | |
| template<jh::concepts::mutex_like M> | |
| atomic_str_ptr | safe_from (std::string_view sv, M &mtx) |
Creates a shared pointer to an immutable_str from a locked string view. | |
| template<concepts::sequence SeqType> | |
| generator< concepts::sequence_value_t< SeqType > > | make_generator (const SeqType &seq) |
Alias of jh::async::make_generator. | |
| template<typename T> | |
| std::vector< T > | to_vector (generator< T > &gen) |
Alias of jh::async::to_vector for generator-based conversion. | |
| template<typename T> | |
| std::deque< T > | to_deque (generator< T > &gen) |
Alias of jh::async::to_deque for generator-based conversion. | |
| using jh::atomic_str_ptr = std::shared_ptr<immutable_str> |
Atomically replaceable handle to an immutable string.
An atomic_str_ptr is simply a std::shared_ptr<immutable_str>.
Since std::shared_ptr has built-in atomic operations (atomic_load, atomic_store, atomic_exchange, atomic_compare_exchange_*, as well as their *_explict forms) and jh::immutable_str is itself immutable, the pointer can be safely loaded, stored, or replaced across threads without any additional synchronization.
std::shared_ptr (C++11+). | using jh::generator = async::generator<T, U> |
Alias of jh::async::generator in the root namespace.
This is a forwarding alias that exposes jh::async::generator<T, U> as jh::generator<T, U> for convenience.
| using jh::observe_pool |
Duck-typed alias of jh::conc::pointer_pool for content-based pooling of immutable objects.
jh::observe_pool<T> provides logical deduplication of shared objects based on content hashing and equality. Objects are observed via std::weak_ptr and are never owned by the pool.
All concurrency, cleanup, and adaptive resizing behavior is defined entirely by jh::conc::pointer_pool, of which observe_pool is a direct alias with fixed template parameters.
| T | The pooled object type. T must be logically immutable, satisfy jh::concepts::extended_hashable, and support content-based operator==. |
<jh/pool> are designed primarily for POSIX platforms and rely on POSIX-style ordering semantics for their performance characteristics. | using jh::ordered_map |
Ordered associative map based on a contiguous-array AVL tree.
This alias provides an ordered map storing unique keys of type K and mapped values of type V. The semantics match those of std::map: keys are unique, elements are stored in sorted key order, and the mapped value is accessible via key lookup or iterator dereferencing. Internally this type is backed by avl::tree_map, using a contiguous storage layout rather than the pointer-based red-black tree used by STL maps.
| K | Key type. |
| V | Mapped value type. |
| Alloc | Allocator used for internal node storage. |
| using jh::ordered_set |
Ordered associative set based on a contiguous-array AVL tree.
This alias provides a set-like container storing unique keys of type K. The semantics match those of std::set: keys are unique, sorted in strictly increasing order, and no mapped value is stored. Internally this type is implemented using avl::tree_map with monostate as its value type, yielding a compact and allocation-free node layout.
| K | Key type stored in the set. |
| Alloc | Allocator used for internal node storage. |
| using jh::resource_pool = jh::conc::flat_pool<Key, Value, jh::hash<Key>, Alloc> |
Convenience alias of jh::conc::flat_pool with behaviorally deduced hashing.
jh::resource_pool<Key, Value, Alloc> is a direct alias of jh::conc::flat_pool that fixes the hash functor to jh::hash<Key>. No additional abstraction layer or duck-typing mechanism is introduced.
The alias relies on jh::hash<Key> to successfully resolve a hashing strategy for Key, following its resolution order: std::hash, ADL-discovered free hash(key), or key.hash().
This design preserves the full behavior and constraints of jh::conc::flat_pool while reducing template verbosity for the common case where no custom hash functor is required.
| Key | The key type defining logical identity. Key must satisfy jh::concepts::extended_hashable and jh::concepts::is_contiguous_reallocable. |
| Value | The value type stored in the pool. Must either be jh::typed::monostate or satisfy jh::concepts::is_contiguous_reallocable. |
| Alloc | Allocator used for internal storage. Defaults to an allocator compatible with the underlying flat_pool value representation. |
jh::resource_pool exists solely to reduce the cognitive and syntactic cost of using flat_pool in the common case. jh::conc::flat_pool directly with an explicit hash functor. | using jh::resource_pool_set = jh::conc::flat_pool<Key, jh::typed::monostate, jh::hash<Key>, Alloc> |
Set-style specialization of jh::resource_pool.
jh::resource_pool_set<Key> is an alias of jh::conc::flat_pool with Value fixed to jh::typed::monostate. It represents a concurrent pool of unique keys with no associated payload.
|
inline |
Creates a shared pointer to an immutable_str.
Constructs a new jh::immutable_str instance from a null-terminated C-string and wraps it in a std::shared_ptr. This is the standard factory function for creating atomic, immutable string objects.
| str | Null-terminated C-string to initialize from. |
atomic_str_ptr) managing the constructed immutable_str instance.immutable_str without intermediate copies or moves. std::shared_ptr and can be safely shared across threads. JH_IMMUTABLE_STR_AUTO_TRIM. immutable_str is non-copyable and non-movable, this factory is the only supported way to allocate it on the heap. std::shared_ptr instance. | generator< concepts::sequence_value_t< SeqType > > jh::async::make_generator | ( | const SeqType & | seq | ) |
Alias of jh::async::make_generator.
This function is re-exported from jh::async into the root namespace to allow construction of generators without qualifying the async namespace.
jh::async::make_generator
|
inline |
Creates a shared pointer to an immutable_str from a locked string view.
Constructs a new jh::immutable_str using a std::string_view and an associated mutex-like object that guards the view's lifetime. This ensures thread-safe initialization from potentially mutable or shared buffers.
| M | Any type satisfying jh::concepts::mutex_like, such as std::mutex, std::shared_mutex, or jh::typed::null_mutex_t. |
| sv | String view referencing existing string data. |
| mtx | Mutex-like object protecting the lifetime of the structure that owns sv. |
atomic_str_ptr) managing the constructed immutable_str instance.| std::logic_error | If sv contains embedded null ('\0') characters. |
mtx correctly protects the memory region referenced by sv. std::string_view refers to data from temporary, mutable, or shared contexts that require explicit synchronization. jh::typed::null_mutex may be used for zero-cost locking. immutable_str cannot be copied or moved, it must always be constructed via this factory or make_atomic(). | std::deque< T > jh::async::to_deque | ( | generator< T > & | gen | ) |
Alias of jh::async::to_deque for generator-based conversion.
This function forwards jh::async::to_deque into the root namespace. In its current form, it operates on jh::async::generator-based sources and collects their yielded values into a std::deque.
Future overloads may extend this facility to additional source types. Overload resolution will rely on distinct parameter signatures, ensuring no ambiguity with the generator-based usage.
jh::async::to_deque | auto jh::to_range | ( | F && | f | ) |
Converts a generator factory (lambda or function) into a repeatable range.
This helper transforms a callable object that returns jh::async::generator<T> (with U == typed::monostate) into a jh::async::generator_range<T>. The resulting object supports multiple independent iterations, since each call to begin() constructs a new generator instance.
The callable must take no arguments:
jh::async::generator<T> func() [=]() -> jh::async::generator<T> { ... } [&]() -> jh::async::generator<T> { ... } [+]() -> jh::async::generator<T> { ... } Any captured state must be enclosed within the lambda's closure. External parameters cannot be forwarded dynamically.
| F | A callable returning jh::async::generator<T>. |
| f | A generator factory function (no arguments). |
| decltype(auto) jh::to_range | ( | Seq && | s | ) |
Converts a sequence into a usable std::ranges::range object.
This is the user-facing interface for range conversion. It guarantees that any valid jh::concepts::sequence can be transformed into an object that models std::ranges::range, regardless of whether the original type is movable, copyable, or a simple sequence-like container.
The conversion is idempotent — if the input already models std::ranges::range and is safely movable or copyable, it is forwarded unchanged. Otherwise, the function wraps or adapts it internally to ensure range compatibility and reference safety.
| Seq | A type satisfying jh::concepts::sequence. |
| s | The input sequence to convert. |
std::ranges::range, ready for direct use in range-based for loops or std::ranges algorithms. | std::vector< T > jh::async::to_vector | ( | generator< T > & | gen | ) |
Alias of jh::async::to_vector for generator-based conversion.
This function forwards jh::async::to_vector into the root namespace. In its current form, it operates on jh::async::generator-based sources and materializes their yielded values into a std::vector.
Additional overloads may be introduced in the future to support other asynchronous or range-like sources. Such overloads will be distinguished by their parameter types and will not conflict with the generator-based form.
jh::async::to_vector