16 #ifndef IOX_UTILS_POSIX_WRAPPER_FILE_LOCK_HPP
17 #define IOX_UTILS_POSIX_WRAPPER_FILE_LOCK_HPP
19 #include "iceoryx_utils/cxx/expected.hpp"
20 #include "iceoryx_utils/cxx/string.hpp"
21 #include "iceoryx_utils/design_pattern/creation.hpp"
27 enum class FileLockError
30 NO_FILE_NAME_PROVIDED,
31 LOCKED_BY_OTHER_PROCESS,
35 INVALID_CHARACTERS_IN_FILE_NAME,
44 SYS_CALL_NOT_IMPLEMENTED,
49 #if defined(QNX) || defined(QNX__) || defined(__QNX__)
50 constexpr
char PATH_PREFIX[] =
"/var/lock/";
52 constexpr
char PATH_PREFIX[] =
"/tmp/";
74 static constexpr int32_t ERROR_CODE = -1;
75 static constexpr int32_t INVALID_FD = -1;
87 int32_t m_fd{INVALID_FD};
94 cxx::expected<FileLockError> initializeFileLock() noexcept;
95 FileLockError convertErrnoToFileLockError(
const int32_t errnum)
const noexcept;
96 cxx::expected<FileLockError> closeFileDescriptor() noexcept;
This pattern can be used if you write an abstraction where you have to throw an exception in the cons...
Definition: creation.hpp:99
Posix file lock C++ wrapping class Following RAII, the lock is acquired on creation and released on d...
Definition: file_lock.hpp:72
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28