16#ifndef IOX_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP
17#define IOX_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP
19#include "iceoryx_hoofs/cxx/expected.hpp"
20#include "iceoryx_hoofs/cxx/string.hpp"
21#include "iceoryx_hoofs/design_pattern/creation.hpp"
27enum class FileLockError
30 LOCKED_BY_OTHER_PROCESS,
33 INVALID_CHARACTERS_IN_FILE_NAME,
42 SYS_CALL_NOT_IMPLEMENTED,
63 static constexpr int32_t ERROR_CODE = -1;
64 static constexpr int32_t INVALID_FD = -1;
65 static constexpr const char LOCK_FILE_SUFFIX[] =
".lock";
66 static constexpr uint64_t FILENAME_LENGTH = platform::IOX_MAX_FILENAME_LENGTH
67 -
sizeof(platform::IOX_LOCK_FILE_PATH_PREFIX) /
sizeof(
char)
68 -
sizeof(LOCK_FILE_SUFFIX) /
sizeof(
char);
81 int32_t m_fd{INVALID_FD};
89 void invalidate()
noexcept;
91 cxx::expected<FileLockError> initializeFileLock()
noexcept;
92 FileLockError convertErrnoToFileLockError(
const int32_t errnum)
const noexcept;
93 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:61
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29