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
jh::conc Namespace Reference

Aggregated namespace for concurrency-aware resource containers. More...

Namespaces

namespace  extension
 Public customization and extension points for jh::conc containers.

Classes

class  flat_pool
 Hash-ordered, contiguous resource interning pool. More...
class  occ_box
 Generic container providing Optimistic Concurrency Control (OCC). More...
class  pointer_pool
 Weak pointer-observed pool for immutable or structurally immutable objects. More...

Functions

template<typename... Boxes, typename... Funcs>
bool apply_to (std::tuple< Boxes &... > boxes, std::tuple< Funcs... > &&funcs)
 Apply functions to multiple occ_boxes atomically.

Detailed Description

Aggregated namespace for concurrency-aware resource containers.

The <jh/concurrency> forwarding header provides a unified, engineering-oriented interface over the concurrency primitives implemented under jh/concurrent/.
Rather than exposing raw locking primitives or requiring users to reason about mutex choreography, jh::conc offers resource-centric containers that encapsulate synchronization internally. APIs are shaped around managed objects, keys, and handles, not explicit lock ownership.
This namespace aggregates facilities such as optimistic-concurrency boxes and pool-based containers with well-defined ownership, observation, and lifetime semantics.
The aggregated header <jh/concurrency> is the recommended entry point for accessing these components. Individual headers under jh/concurrent/ remain fully supported.

Function Documentation

◆ apply_to()

template<typename... Boxes, typename... Funcs>
bool jh::conc::apply_to ( std::tuple< Boxes &... > boxes,
std::tuple< Funcs... > && funcs )

Apply functions to multiple occ_boxes atomically.

Choosing between copy-based and shared_ptr-based apply_to

  • Copy-based

    • Each box value is deep-copied before applying the function.
    • Best suited for small or trivially copyable types.
    • Ensures that modifications are isolated until commit.
    • Functions must be of type void(T&).

  • Shared_ptr-based
    • The function constructs a new shared_ptr<T> instead of copying the old object.
    • Best for large or complex types where deep copies are expensive.
    • When mixing small and large objects in one transaction, prefer the shared_ptr-based version for consistency and speed.
    • Functions must be of type std::shared_ptr<T>(const std::shared_ptr<T>&).

Both styles are mutually exclusive for a single transaction. Attempting to mix them will fail at compile time.

Template Parameters
BoxesThe set of occ_box types
FuncsThe set of functions (one per box)
Parameters
boxesTuple of references to occ_boxes
funcsTuple of functions to apply
Returns
true if commit succeeds, false otherwise.