|
lintel 0.2.0
|
#include <ShmConstructors.h>
Public Member Functions | |
| SegmentSemaphoreGuard (boost::interprocess::named_semaphore &semaphore, std::chrono::steady_clock::duration timeout=kDefaultWaitTimeout) | |
| ~SegmentSemaphoreGuard () | |
| SegmentSemaphoreGuard (const SegmentSemaphoreGuard &)=delete | |
| SegmentSemaphoreGuard & | operator= (const SegmentSemaphoreGuard &)=delete |
Static Public Attributes | |
| static constexpr std::chrono::seconds | kDefaultWaitTimeout { 30 } |
RAII guard that acquires (default) the segment remap semaphore and releases it on destruction. Used as a cross-process mutex around the shared memory remap / construct critical sections.
The acquisition is bounded: a process that crashes while holding the semaphore leaves its count at zero forever, so an unbounded wait() would deadlock every other process. Instead the guard times out and throws, turning the silent hang into an actionable error (the orphaned handle can be inspected/removed out of band).
|
inlineexplicit |
| semaphore | semaphore of the segment to guard |
| timeout | upper bound for acquiring the semaphore |
| std::runtime_error | if the semaphore could not be acquired within the timeout (e.g. a previous holder crashed) |
|
inline |
|
delete |
|
delete |
|
staticconstexpr |
Default time to wait for the semaphore before giving up. Generous, because the guarded critical sections are short (remap/construct).