|
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 condition variable primitive implemented via shared memory or named events. 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 <chrono>#include <stdexcept>#include <string>#include <sys/mman.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <cerrno>#include <cstring>#include <pthread.h>Go to the source code of this file.
Classes | |
| class | jh::sync::ipc::process_cond_var< S, HighPriv > |
| Cross-process condition variable primitive (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 condition variable primitive implemented via shared memory or named events.
jh::sync::ipc::process_cond_var is an inter-process signaling primitive modeled after pthread_cond_t / std::condition_variable_any. It provides a minimal, globally visible synchronization point usable across processes, implemented entirely via OS-named IPC mechanisms.
shm_open + mmap + pthread_cond_t. PTHREAD_PROCESS_SHARED. CreateEventA and WaitForSingleObject. Global\ namespace for inter-process visibility. Global\ named events. In the jh-toolkit IPC model, Windows is treated as a second-class citizen: API compatibility and basic semantics are preserved, but exact parity of behavior (particularly in multi-notification semantics) is not guaranteed.
notify_all(n) signals up to n waiting processes (default 32). Exceeding waiters remain blocked until the next call. notify_all() simulates this behavior by setting the event for ~1 ms, which is sufficient for most engineering use cases but not strictly equivalent. process_counter to implement precise wake control. On POSIX systems, process_cond_var requires no special privileges. On Windows, due to Global\ namespace policy, creation and access require administrative rights. The same restriction applies to process_counter.
pthread_mutex_t or event handle. process_mutex, process_counter) to form higher-level protocols. shm_unlink() on the internal shared-memory segment. process_cond_var is an IPC primitive. It does not guarantee fairness or broadcast consistency across all platforms. Developers are encouraged to compose it with process_mutex or process_counter when building higher-level coordination patterns.