|
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.
|
Cross-process shared-memory container for a single POD-like object. More...
#include <jh/synchronous/ipc/process_shm_obj.h>
Public Member Functions | |
| process_shm_obj (const process_shm_obj &)=delete | |
| process_shm_obj & | operator= (const process_shm_obj &)=delete |
| T * | ptr () noexcept |
| Obtain non-const pointer to the shared object. | |
| const T * | ptr () const noexcept |
| Obtain const pointer to the shared object. | |
| T & | ref () noexcept |
| Obtain non-const reference to the shared object. | |
| const T & | ref () const noexcept |
| Obtain const reference to the shared object. | |
| T * | operator-> () noexcept |
| Operator-> convenience accessor. | |
| const T * | operator-> () const noexcept |
| Const Operator-> convenience accessor. | |
| T & | operator* () noexcept |
| Operator* convenience accessor. | |
| const T & | operator* () const noexcept |
| Const Operator* convenience accessor. | |
| lock_t & | lock () noexcept |
| Accessor for the inter-process mutex protecting this shared object. | |
Static Public Member Functions | |
| static process_shm_obj & | instance () |
| Singleton accessor. | |
| static void | flush_acquire () noexcept |
| Acquire fence ensuring visibility of preceding writes by other processes. | |
| static void | flush_release () noexcept |
| Release fence ensuring visibility of local writes to other processes. | |
| static void | flush_seq () noexcept |
| Sequential-consistency fence for full memory ordering. | |
| static void | unlink () |
| Remove the shared-memory region and associated mutexes (POSIX only). | |
| static void | unlink ()=delete |
| Disabled if HighPriv == false. Non-privileged variants cannot call unlink(). | |
Cross-process shared-memory container for a single POD-like object.
Provides a memory-mapped instance of T visible to all processes sharing the same name S. Synchronization and initialization are managed internally via named process-level mutexes.
| S | Shared-memory name literal (letters, digits, dot, dash, underscore). |
| T | POD-like type satisfying cv_free_pod_like. |
| HighPriv | Enables privileged operations (e.g. unlink()). |
|
inlinestaticnoexcept |
Acquire fence ensuring visibility of preceding writes by other processes.
Use this before reading from the shared object to guarantee memory ordering.
|
inlinestaticnoexcept |
Release fence ensuring visibility of local writes to other processes.
Call this before releasing the lock after modifying the shared object.
|
inlinestaticnoexcept |
Sequential-consistency fence for full memory ordering.
Equivalent to std::atomic_thread_fence(std::memory_order_seq_cst).
|
inlinenodiscardnoexcept |
Accessor for the inter-process mutex protecting this shared object.
process_mutex<S + ".loc">.
|
inlinenodiscardnoexcept |
Const Operator* convenience accessor.
|
inlinenodiscardnoexcept |
Operator* convenience accessor.
|
inlinenodiscardnoexcept |
Const Operator-> convenience accessor.
|
inlinenodiscardnoexcept |
Operator-> convenience accessor.
|
inlinenodiscardnoexcept |
Obtain const pointer to the shared object.
|
inlinenodiscardnoexcept |
Obtain non-const pointer to the shared object.
T.
|
inlinenodiscardnoexcept |
Obtain const reference to the shared object.
|
inlinenodiscardnoexcept |
Obtain non-const reference to the shared object.
|
inlinestatic |
Remove the shared-memory region and associated mutexes (POSIX only).
shm_unlink() for the mapped object name. process_mutex and
process_mutex<S + ".loc">. Ignores ENOENT if the object does not exist. Throws std::runtime_error on other errors.
The operation is idempotent and safe to call multiple times.
Once all processes unmap, the region is destroyed by the OS.
Windows provides no explicit unlink; shared handles are released automatically
when all processes close them.