holoscan::FileFIFOMutex
holoscan::FileFIFOMutex
A class that implements a file-based FIFO mutex.
This class implements a file-based mutex that can be used to synchronize multiple processes. It uses a lock file to synchronize the processes and a queue file to store the process IDs of the processes that are waiting to acquire the lock.
Constructors
FileFIFOMutex
Overload 3
Deleted overloads
Constructs a new file-backed mutex at the given path and a queue file at file_path.queue, if not already present.
It also opens both the files.
Parameters
The path to the mutex file.
Destructor
~FileFIFOMutex
Unlocks the mutex if it was locked.
Closes the queue and lock files.
Assignment operators
operator=
Methods
set_wait_time_ms
Sets the wait time for the lock.
The wait time is applied when the queue file is being locked. If the queue file is not available for lock within the wait time, then the lock is not acquired. If the wait time is less than or equal to 0, then it blocks until the lock is acquired.
Parameters
The wait time in milliseconds.
lock
Locks the mutex after writing the current process’ PID to the queue.
Waits for the queue file to be unlocked to write its own PID to the queue, depending on the wait time.
unlock
Unlocks the mutex by removing itself from the queue and unlocking the mutex.
locked
Returns true if the mutex is locked.
Returns: false When the mutex is not locked.