16 #ifndef IOX_UTILS_POSIX_WRAPPER_MESSAGE_QUEUE_HPP
17 #define IOX_UTILS_POSIX_WRAPPER_MESSAGE_QUEUE_HPP
19 #include "iceoryx_utils/cxx/optional.hpp"
20 #include "iceoryx_utils/design_pattern/creation.hpp"
21 #include "iceoryx_utils/internal/posix_wrapper/ipc_channel.hpp"
22 #include "iceoryx_utils/internal/units/duration.hpp"
23 #include "iceoryx_utils/platform/fcntl.hpp"
24 #include "iceoryx_utils/platform/mqueue.hpp"
25 #include "iceoryx_utils/platform/stat.hpp"
52 static constexpr mqd_t INVALID_DESCRIPTOR = -1;
53 static constexpr int32_t ERROR_CODE = -1;
54 static constexpr
size_t SHORTEST_VALID_QUEUE_NAME = 2;
55 static constexpr
size_t NULL_TERMINATOR_SIZE = 1;
56 static constexpr
size_t MAX_MESSAGE_SIZE = 4096;
72 static cxx::expected<bool, IpcChannelError> unlinkIfExists(
const IpcChannelName_t& name);
79 cxx::expected<IpcChannelError>
send(
const std::string& msg)
const;
85 cxx::expected<std::string, IpcChannelError>
receive()
const;
95 cxx::expected<bool, IpcChannelError> isOutdated();
99 const IpcChannelMode mode,
100 const IpcChannelSide channelSide,
101 const size_t maxMsgSize = MAX_MESSAGE_SIZE,
102 const uint64_t maxMsgNumber = 10u);
104 cxx::expected<int32_t, IpcChannelError>
105 open(
const IpcChannelName_t& name,
const IpcChannelMode mode,
const IpcChannelSide channelSide);
107 cxx::expected<IpcChannelError> close();
108 cxx::expected<IpcChannelError> unlink();
111 static cxx::expected<IpcChannelName_t, IpcChannelError>
116 struct mq_attr m_attributes;
117 mqd_t m_mqDescriptor = INVALID_DESCRIPTOR;
118 IpcChannelSide m_channelSide;
121 static constexpr
int TIMEOUT_ERRNO = EINTR;
123 static constexpr
int TIMEOUT_ERRNO = ETIMEDOUT;
126 static constexpr mode_t m_filemode{S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH};
This pattern can be used if you write an abstraction where you have to throw an exception in the cons...
Definition: creation.hpp:99
Wrapper class for posix message queue.
Definition: message_queue.hpp:50
cxx::expected< std::string, IpcChannelError > receive() const
receive message from queue using std::string.
cxx::expected< std::string, IpcChannelError > timedReceive(const units::Duration &timeout) const
try to receive message from queue for a given timeout duration using std::string. Only defined for NO...
cxx::expected< IpcChannelError > destroy()
close and remove message queue.
cxx::expected< IpcChannelError > timedSend(const std::string &msg, const units::Duration &timeout) const
try to send a message to the queue for a given timeout duration using std::string
cxx::expected< IpcChannelError > send(const std::string &msg) const
send a message to queue using std::string.
Definition: duration.hpp:77
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28
helper struct to create an expected which is signalling an error more easily
Definition: expected.hpp:108