|
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.
|
Fixed-capacity control block container for non-copyable, non-movable types. More...
#include <memory>#include <vector>#include <type_traits>#include "jh/conceptual/container_traits.h"Go to the source code of this file.
Classes | |
| class | jh::sync::control_buf< T, Alloc > |
| Fixed-capacity, block-allocated container for control-only types (e.g., mutexes, atomics). More... | |
Namespaces | |
| namespace | jh::sync |
| Aggregated entry point for synchronization and coordination facilities. | |
Macros | |
| #define | JH_CTRL_BUFFER_BLOCK_SIZE 64 |
| Specifies the number of elements allocated per block in jh::sync::control_buf (default: 64). | |
Fixed-capacity control block container for non-copyable, non-movable types.
jh::sync::control_buf<T> is a special-purpose, heap-backed container designed to store control-related types (such as std::mutex or std::atomic) that are:
std::vector, std::deque, etc. Unlike STL containers, this type intentionally disables element-wise relocation such as move or copy during reallocation. This is critical for storing control-type objects whose addresses must remain stable during their lifetime — for instance, synchronization primitives like std::mutex, std::atomic, or file descriptors.
This constraint is formalized by rejecting types that satisfy jh::concepts::is_contiguous_reallocable, which checks whether a type supports move- or copy-based relocation under contiguous growth strategies.
Internally, control_buf uses a block-allocated growth model, where memory is allocated in fixed-size blocks. These blocks are never relocated, and each element is constructed in-place, preserving pointer stability.
JH_CTRL_BUFFER_BLOCK_SIZE elements (default: 64). This can be configured via a preprocessor macro. std::mutex). std::deque), but never at element level. emplace_back() to append default-constructed elements. resize() or clear(). std::allocator_traits. std::mutex, std::atomic).1.4.x
2025
| #define JH_CTRL_BUFFER_BLOCK_SIZE 64 |
Specifies the number of elements allocated per block in jh::sync::control_buf (default: 64).
This macro controls the fixed block size used for internal block-based allocation. Larger values reduce allocation frequency but increase per-block memory usage.