Class NamedPipe

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

Class Documentation

class NamedPipe : public DesignPattern::Creation<NamedPipe, IpcChannelError>

Public Types

using Message_t = cxx::string<MAX_MESSAGE_SIZE>
using MessageQueue_t = concurrent::LockFreeQueue<Message_t, MAX_NUMBER_OF_MESSAGES>

Public Functions

NamedPipe(const NamedPipe&) = delete
NamedPipe &operator=(const NamedPipe&) = delete
NamedPipe() noexcept

For compatibility with IpcChannel alias, default ctor which creates an uninitialized NamedPipe.

NamedPipe(NamedPipe &&rhs) noexcept
NamedPipe &operator=(NamedPipe &&rhs) noexcept
~NamedPipe() noexcept
cxx::expected<IpcChannelError> destroy() noexcept

destroys an initialized named pipe.

Returns:

is always successful

cxx::expected<bool, IpcChannelError> isOutdated() noexcept

for compatibility with IpcChannelError

Returns:

always false

cxx::expected<IpcChannelError> trySend(const std::string &message) const noexcept

tries to send a message via the named pipe. if the pipe is full IpcChannelError::TIMEOUT is returned

Returns:

on failure an error which describes the failure

cxx::expected<IpcChannelError> send(const std::string &message) const noexcept

sends a message via the named pipe. if the pipe is full this call is blocking until the message could be delivered

Parameters:

message[in] the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE

Returns:

success when message was sent otherwise an error which describes the failure

cxx::expected<IpcChannelError> timedSend(const std::string &message, const units::Duration &timeout) const noexcept

sends a message via the named pipe.

Parameters:
  • message[in] the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE

  • timeout[in] the timeout on how long this method should retry to send the message

Returns:

success when message was sent otherwise an error which describes the failure

cxx::expected<std::string, IpcChannelError> tryReceive() const noexcept

tries to receive a message via the named pipe. if the pipe is empty IpcChannelError::TIMEOUT is returned

Returns:

on success a string containing the message, otherwise an error which describes the failure

cxx::expected<std::string, IpcChannelError> receive() const noexcept

receives a message via the named pipe. if the pipe is empty this call is blocking until a message was received

Returns:

on success a string containing the message, otherwise an error which describes the failure

cxx::expected<std::string, IpcChannelError> timedReceive(const units::Duration &timeout) const noexcept

receives a message via the named pipe.

Parameters:

timeout[in] the timeout on how long this method should retry to receive a message

Returns:

on success a string containing the message, otherwise an error which describes the failure

Public Static Functions

static cxx::expected<bool, IpcChannelError> unlinkIfExists(const IpcChannelName_t &name) noexcept

removes a named pipe artifact from the system

Returns:

true if the artifact was removed, false when no artifact was found and IpcChannelError::INTERNAL_LOGIC_ERROR when shm_unlink failed

Public Static Attributes

static constexpr uint64_t MAX_MESSAGE_SIZE = 4U * 1024U
static constexpr uint64_t MAX_NUMBER_OF_MESSAGES = 10U
static constexpr uint64_t NULL_TERMINATOR_SIZE = 0U
static constexpr units::Duration CYCLE_TIME = units::Duration::fromMilliseconds(10)
static constexpr const char NAMED_PIPE_PREFIX[] = "iox_np_"

Friends

friend class DesignPattern::Creation< NamedPipe, IpcChannelError >