|
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 integer counter implemented via named shared memory. More...
#include "jh/metax/t_str.h"#include "jh/macros/platform.h"#include "jh/synchronous/ipc/process_mutex.h"#include "jh/synchronous/ipc/ipc_limits.h"#include <cstring>#include <cerrno>#include <stdexcept>#include <string>#include <functional>#include <sys/mman.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>Go to the source code of this file.
Classes | |
| class | jh::sync::ipc::process_counter< S, HighPriv > |
| Cross-process integer counter stored in shared memory (POSIX / Win32). More... | |
Namespaces | |
| namespace | jh::sync |
| Aggregated entry point for synchronization and coordination facilities. | |
| namespace | jh::sync::ipc |
| Synchronous inter-process coordination primitives. | |
Cross-process shared integer counter implemented via named shared memory.
jh::sync::ipc::process_counter provides a process-visible 64-bit integer stored in OS-level shared memory and synchronized by a per-instance process_mutex<S + ".loc">. It behaves as a globally accessible atomic counter with read-modify-write semantics enforced through inter-process locking.
shm_open + mmap. JH_PROCESS_MUTEX_SHARED (0644 or 0666). CreateFileMapping + MapViewOfFile. Global\ namespace for inter-process visibility. Global\ objects. [A-Za-z0-9_.-]. '/'); it is added automatically when required by the OS. jh::sync::ipc::limits::valid_object_name<S, limits::max_name_length - 4>, where -4 reserves space for the ".loc" suffix used by its mutex. shm_unlink(); existing mappings remain valid until unmapped by all processes. The operation is idempotent. On Windows, process_counter requires administrator privilege because shared memory objects are created in the Global\ namespace. This does not affect POSIX systems.