From 57b1845bdbdc365ce2a4460f34567921ec3b9f73 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 26 Oct 2023 00:26:55 +0200 Subject: [PATCH 01/12] iox-#1391 Move 'message_queue' to 'posix/ipc' --- .../release-notes/iceoryx-unreleased.md | 2 +- iceoryx_dust/BUILD.bazel | 4 +- iceoryx_dust/CMakeLists.txt | 4 +- .../ipc/include/iox}/message_queue.hpp | 50 +++++++++---------- .../ipc/source}/message_queue.cpp | 35 ++++++------- iceoryx_hoofs/cmake/IceoryxPlatform.cmake | 4 +- .../internal/runtime/ipc_interface_base.hpp | 2 +- .../source/runtime/ipc_interface_base.cpp | 2 +- .../test_mq_interface_startup_race.cpp | 2 +- .../test_runtime_ipc_interface.cpp | 2 +- 10 files changed, 56 insertions(+), 51 deletions(-) rename iceoryx_dust/{include/iceoryx_dust/posix_wrapper => posix/ipc/include/iox}/message_queue.hpp (72%) rename iceoryx_dust/{source/posix_wrapper => posix/ipc/source}/message_queue.cpp (90%) diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 730228d136..2c0e379f79 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -998,7 +998,7 @@ #include "iceoryx_hoofs/posix_wrapper/internal/message_queue.hpp" // after - #include "iceoryx_dust/posix_wrapper/message_queue.hpp" + #include "iox/message_queue.hpp" ``` ```cpp diff --git a/iceoryx_dust/BUILD.bazel b/iceoryx_dust/BUILD.bazel index a8ad11ef32..5374b4573f 100644 --- a/iceoryx_dust/BUILD.bazel +++ b/iceoryx_dust/BUILD.bazel @@ -32,10 +32,11 @@ cc_library( srcs = glob([ "cli/source/**/*.cpp", "filesystem/source/**/*.cpp", + "posix/ipc/source/**/*.cpp", "source/**/*.cpp", "source/**/*.hpp", ]), - hdrs = glob(["include/**"]) + glob(["cli/**"]) + glob(["container/**"]) + glob(["filesystem/**"]) + glob(["memory/**"]) + glob(["utility/**"]) + glob(["vocabulary/**"]) + [ + hdrs = glob(["include/**"]) + glob(["cli/**"]) + glob(["container/**"]) + glob(["filesystem/**"]) + glob(["memory/**"]) + glob(["utility/**"]) + glob(["posix/ipc/**"]) + glob(["vocabulary/**"]) + [ ":iceoryx_dust_deployment_hpp", ], includes = [ @@ -44,6 +45,7 @@ cc_library( "filesystem/include/", "include", "memory/include/", + "posix/ipc/include/", "utility/include/", "vocabulary/include/", ], diff --git a/iceoryx_dust/CMakeLists.txt b/iceoryx_dust/CMakeLists.txt index 0333330f49..d5014da80a 100644 --- a/iceoryx_dust/CMakeLists.txt +++ b/iceoryx_dust/CMakeLists.txt @@ -51,6 +51,7 @@ iox_add_library( ${PROJECT_SOURCE_DIR}/container/include ${PROJECT_SOURCE_DIR}/filesystem/include ${PROJECT_SOURCE_DIR}/memory/include + ${PROJECT_SOURCE_DIR}/posix/ipc/include ${PROJECT_SOURCE_DIR}/utility/include ${PROJECT_SOURCE_DIR}/vocabulary/include ${CMAKE_BINARY_DIR}/generated/iceoryx_dust/include @@ -60,6 +61,7 @@ iox_add_library( container/include/ filesystem/include/ memory/include/ + posix/ipc/include/ utility/include/ vocabulary/include/ FILES @@ -71,7 +73,7 @@ iox_add_library( filesystem/source/file_reader.cpp source/posix_wrapper/named_pipe.cpp source/posix_wrapper/signal_watcher.cpp - source/posix_wrapper/message_queue.cpp + posix/ipc/source/message_queue.cpp ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/iceoryx_dust_deployment.hpp.in" diff --git a/iceoryx_dust/include/iceoryx_dust/posix_wrapper/message_queue.hpp b/iceoryx_dust/posix/ipc/include/iox/message_queue.hpp similarity index 72% rename from iceoryx_dust/include/iceoryx_dust/posix_wrapper/message_queue.hpp rename to iceoryx_dust/posix/ipc/include/iox/message_queue.hpp index 6c57c2593f..2c2f7a965e 100644 --- a/iceoryx_dust/include/iceoryx_dust/posix_wrapper/message_queue.hpp +++ b/iceoryx_dust/posix/ipc/include/iox/message_queue.hpp @@ -15,8 +15,9 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_DUST_POSIX_WRAPPER_MESSAGE_QUEUE_HPP -#define IOX_DUST_POSIX_WRAPPER_MESSAGE_QUEUE_HPP + +#ifndef IOX_DUST_POSIX_IPC_MESSAGE_QUEUE_HPP +#define IOX_DUST_POSIX_IPC_MESSAGE_QUEUE_HPP #include "iceoryx_hoofs/internal/posix_wrapper/ipc_channel.hpp" #include "iceoryx_platform/fcntl.hpp" @@ -29,14 +30,12 @@ namespace iox { -namespace posix -{ class MessageQueueBuilder; /// @brief Wrapper class for posix message queue /// /// @code -/// auto mq = iox::posix::MessageQueueBuilder() +/// auto mq = iox::MessageQueueBuilder() /// .name("/MqName123") /// .channelSide(iox::posix::IpcChannelSide::CLIENT) /// .create(); @@ -68,27 +67,28 @@ class MessageQueue ~MessageQueue() noexcept; - static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; + static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; /// @brief send a message to queue using std::string. /// @return true if sent without errors, false otherwise - expected send(const std::string& msg) const noexcept; + expected send(const std::string& msg) const noexcept; /// @todo iox-#1693 zero copy receive with receive(iox::string&); iox::string would be the buffer for mq_receive /// @brief receive message from queue using std::string. /// @return number of characters received. In case of an error, returns -1 and msg is empty. - expected receive() const noexcept; + expected receive() const noexcept; /// @brief try to receive message from queue for a given timeout duration using std::string. Only defined /// for NON_BLOCKING == false. /// @return optional containing the received string. In case of an error, nullopt type is returned. - expected timedReceive(const units::Duration& timeout) const noexcept; + expected timedReceive(const units::Duration& timeout) const noexcept; /// @brief try to send a message to the queue for a given timeout duration using std::string - expected timedSend(const std::string& msg, const units::Duration& timeout) const noexcept; + expected timedSend(const std::string& msg, + const units::Duration& timeout) const noexcept; - static expected isOutdated() noexcept; + static expected isOutdated() noexcept; private: friend class MessageQueueBuilder; @@ -96,23 +96,24 @@ class MessageQueue MessageQueue(const IpcChannelName_t& name, const mq_attr attributes, mqd_t mqDescriptor, - const IpcChannelSide channelSide) noexcept; + const posix::IpcChannelSide channelSide) noexcept; - static expected - open(const IpcChannelName_t& name, mq_attr& attributes, const IpcChannelSide channelSide) noexcept; + static expected + open(const IpcChannelName_t& name, mq_attr& attributes, const posix::IpcChannelSide channelSide) noexcept; - expected close() noexcept; - expected unlink() noexcept; - IpcChannelError errnoToEnum(const int32_t errnum) const noexcept; - static IpcChannelError errnoToEnum(const IpcChannelName_t& name, const int32_t errnum) noexcept; - static expected sanitizeIpcChannelName(const IpcChannelName_t& name) noexcept; - expected destroy() noexcept; + expected close() noexcept; + expected unlink() noexcept; + posix::IpcChannelError errnoToEnum(const int32_t errnum) const noexcept; + static posix::IpcChannelError errnoToEnum(const IpcChannelName_t& name, const int32_t errnum) noexcept; + static expected + sanitizeIpcChannelName(const IpcChannelName_t& name) noexcept; + expected destroy() noexcept; private: IpcChannelName_t m_name; mq_attr m_attributes{}; mqd_t m_mqDescriptor = INVALID_DESCRIPTOR; - IpcChannelSide m_channelSide = IpcChannelSide::CLIENT; + posix::IpcChannelSide m_channelSide = posix::IpcChannelSide::CLIENT; #ifdef __QNX__ static constexpr int TIMEOUT_ERRNO = EINTR; @@ -132,7 +133,7 @@ class MessageQueueBuilder IOX_BUILDER_PARAMETER(IpcChannelName_t, name, "") /// @brief Defines how the message queue is opened, i.e. as client or server - IOX_BUILDER_PARAMETER(IpcChannelSide, channelSide, IpcChannelSide::CLIENT) + IOX_BUILDER_PARAMETER(posix::IpcChannelSide, channelSide, posix::IpcChannelSide::CLIENT) /// @brief Defines the max message size of the message queue IOX_BUILDER_PARAMETER(uint64_t, maxMsgSize, MessageQueue::MAX_MESSAGE_SIZE) @@ -143,10 +144,9 @@ class MessageQueueBuilder public: /// @brief create a message queue /// @return On success a 'MessageQueue' is returned and on failure an 'IpcChannelError'. - expected create() const noexcept; + expected create() const noexcept; }; -} // namespace posix } // namespace iox -#endif // IOX_DUST_POSIX_WRAPPER_MESSAGE_QUEUE_HPP +#endif // IOX_DUST_POSIX_IPC_MESSAGE_QUEUE_HPP diff --git a/iceoryx_dust/source/posix_wrapper/message_queue.cpp b/iceoryx_dust/posix/ipc/source/message_queue.cpp similarity index 90% rename from iceoryx_dust/source/posix_wrapper/message_queue.cpp rename to iceoryx_dust/posix/ipc/source/message_queue.cpp index a1e0f3395f..5cae8a7b6e 100644 --- a/iceoryx_dust/source/posix_wrapper/message_queue.cpp +++ b/iceoryx_dust/posix/ipc/source/message_queue.cpp @@ -16,7 +16,7 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/message_queue.hpp" +#include "iox/message_queue.hpp" #include "iceoryx_hoofs/posix_wrapper/posix_call.hpp" #include "iceoryx_platform/fcntl.hpp" #include "iceoryx_platform/platform_correction.hpp" @@ -28,8 +28,8 @@ namespace iox { -namespace posix -{ +using namespace iox::posix; + expected MessageQueueBuilder::create() const noexcept { auto sanitzedNameResult = MessageQueue::sanitizeIpcChannelName(m_name); @@ -47,7 +47,7 @@ expected MessageQueueBuilder::create() const noex if (m_channelSide == IpcChannelSide::SERVER) { - posixCall(mq_unlink)(sanitizedName.c_str()) + posix::posixCall(mq_unlink)(sanitizedName.c_str()) .failureReturnValue(MessageQueue::ERROR_CODE) .ignoreErrnos(ENOENT) .evaluate() @@ -134,7 +134,7 @@ expected MessageQueue::unlinkIfExists(const IpcChannelNam } - auto mqCall = posixCall(mq_unlink)(sanitizedIpcChannelName->c_str()) + auto mqCall = posix::posixCall(mq_unlink)(sanitizedIpcChannelName->c_str()) .failureReturnValue(ERROR_CODE) .ignoreErrnos(ENOENT) .evaluate(); @@ -176,8 +176,9 @@ expected MessageQueue::send(const std::string& msg) const return err(IpcChannelError::MESSAGE_TOO_LONG); } - auto mqCall = - posixCall(mq_send)(m_mqDescriptor, msg.c_str(), messageSize, 1U).failureReturnValue(ERROR_CODE).evaluate(); + auto mqCall = posix::posixCall(mq_send)(m_mqDescriptor, msg.c_str(), messageSize, 1U) + .failureReturnValue(ERROR_CODE) + .evaluate(); if (mqCall.has_error()) { @@ -193,7 +194,7 @@ expected MessageQueue::receive() const noexcept /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) char message[MAX_MESSAGE_SIZE]; - auto mqCall = posixCall(mq_receive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr) + auto mqCall = posix::posixCall(mq_receive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr) .failureReturnValue(ERROR_CODE) .evaluate(); @@ -227,10 +228,11 @@ MessageQueue::open(const IpcChannelName_t& name, mq_attr& attributes, const IpcC // the mask will be applied to the permissions, therefore we need to set it to 0 mode_t umaskSaved = umask(0); - auto mqCall = posixCall(iox_mq_open4)(sanitizedName.c_str(), openFlags, MessageQueue::FILE_MODE, &attributes) - .failureReturnValue(MessageQueue::INVALID_DESCRIPTOR) - .suppressErrorMessagesForErrnos(ENOENT) - .evaluate(); + auto mqCall = + posix::posixCall(iox_mq_open4)(sanitizedName.c_str(), openFlags, MessageQueue::FILE_MODE, &attributes) + .failureReturnValue(MessageQueue::INVALID_DESCRIPTOR) + .suppressErrorMessagesForErrnos(ENOENT) + .evaluate(); umask(umaskSaved); @@ -245,7 +247,7 @@ MessageQueue::open(const IpcChannelName_t& name, mq_attr& attributes, const IpcC expected MessageQueue::close() noexcept { - auto mqCall = posixCall(mq_close)(m_mqDescriptor).failureReturnValue(ERROR_CODE).evaluate(); + auto mqCall = posix::posixCall(mq_close)(m_mqDescriptor).failureReturnValue(ERROR_CODE).evaluate(); if (mqCall.has_error()) { @@ -262,7 +264,7 @@ expected MessageQueue::unlink() noexcept return ok(); } - auto mqCall = posixCall(mq_unlink)(m_name.c_str()).failureReturnValue(ERROR_CODE).evaluate(); + auto mqCall = posix::posixCall(mq_unlink)(m_name.c_str()).failureReturnValue(ERROR_CODE).evaluate(); if (mqCall.has_error()) { return err(errnoToEnum(mqCall.error().errnum)); @@ -278,7 +280,7 @@ expected MessageQueue::timedReceive(const units::D /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) char message[MAX_MESSAGE_SIZE]; - auto mqCall = posixCall(mq_timedreceive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr, &timeOut) + auto mqCall = posix::posixCall(mq_timedreceive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr, &timeOut) .failureReturnValue(ERROR_CODE) // don't use the suppressErrorMessagesForErrnos method since QNX used EINTR instead of ETIMEDOUT .ignoreErrnos(TIMEOUT_ERRNO) @@ -310,7 +312,7 @@ expected MessageQueue::timedSend(const std::string& msg, timespec timeOut = timeout.timespec(units::TimeSpecReference::Epoch); - auto mqCall = posixCall(mq_timedsend)(m_mqDescriptor, msg.c_str(), messageSize, 1U, &timeOut) + auto mqCall = posix::posixCall(mq_timedsend)(m_mqDescriptor, msg.c_str(), messageSize, 1U, &timeOut) .failureReturnValue(ERROR_CODE) // don't use the suppressErrorMessagesForErrnos method since QNX used EINTR instead of ETIMEDOUT .ignoreErrnos(TIMEOUT_ERRNO) @@ -406,5 +408,4 @@ expected MessageQueue::sanitizeIpcChannelName return ok(name); } -} // namespace posix } // namespace iox diff --git a/iceoryx_hoofs/cmake/IceoryxPlatform.cmake b/iceoryx_hoofs/cmake/IceoryxPlatform.cmake index 27f9dd7ae0..5f143d95ef 100644 --- a/iceoryx_hoofs/cmake/IceoryxPlatform.cmake +++ b/iceoryx_hoofs/cmake/IceoryxPlatform.cmake @@ -80,7 +80,7 @@ function(iox_create_lsan_runtime_blacklist BLACKLIST_FILE_PATH) # count bytes template # 8 642 libacl.so.1 # 1 24 iox::posix::UnixDomainSocket::timedReceive - # 1 24 iox::posix::MessageQueue::receive + # 1 24 iox::MessageQueue::receive if(NOT EXISTS ${BLACKLIST_FILE_PATH}) file(WRITE ${BLACKLIST_FILE_PATH} "# This file is auto-generated from iceoryx_hoofs/cmake/IceoryxPlatform.cmake\n") file(APPEND ${BLACKLIST_FILE_PATH} "#leak:libacl.so.1\n") @@ -131,7 +131,7 @@ if(ADDRESS_SANITIZER OR THREAD_SANITIZER) elseif(THREAD_SANITIZER) set(ICEORYX_SANITIZER_FLAGS ${ICEORYX_SANITIZER_COMMON_FLAGS} ${ICEORYX_THREAD_SANITIZER_FLAGS} CACHE INTERNAL "") endif() - + # unset local variables , to avoid polluting global space unset(ICEORYX_SANITIZER_BLACKLIST) unset(ICEORYX_SANITIZER_COMMON_FLAGS) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp b/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp index 22dd383396..b73d34bbd0 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp @@ -32,9 +32,9 @@ #include "iox/optional.hpp" #include "iox/relative_pointer.hpp" -#include "iceoryx_dust/posix_wrapper/message_queue.hpp" #include "iceoryx_dust/posix_wrapper/named_pipe.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/unix_domain_socket.hpp" +#include "iox/message_queue.hpp" #include #include diff --git a/iceoryx_posh/source/runtime/ipc_interface_base.cpp b/iceoryx_posh/source/runtime/ipc_interface_base.cpp index bb11b7f6e4..8485720ef7 100644 --- a/iceoryx_posh/source/runtime/ipc_interface_base.cpp +++ b/iceoryx_posh/source/runtime/ipc_interface_base.cpp @@ -264,7 +264,7 @@ void IpcInterface::cleanupOutdatedIpcChannel(const RuntimeName_t template class IpcInterface; template class IpcInterface; -template class IpcInterface; +template class IpcInterface; } // namespace runtime } // namespace iox diff --git a/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp b/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp index c2d3145351..f8e71c48bc 100644 --- a/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp +++ b/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp @@ -18,11 +18,11 @@ #include "iceoryx_posh/iceoryx_posh_types.hpp" #include "test.hpp" -#include "iceoryx_dust/posix_wrapper/message_queue.hpp" #include "iceoryx_hoofs/posix_wrapper/posix_call.hpp" #include "iceoryx_posh/internal/runtime/ipc_message.hpp" #include "iceoryx_posh/internal/runtime/ipc_runtime_interface.hpp" #include "iox/duration.hpp" +#include "iox/message_queue.hpp" #include "iox/std_string_support.hpp" diff --git a/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp b/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp index cc0082b298..271e8de44c 100644 --- a/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp +++ b/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp @@ -15,11 +15,11 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/message_queue.hpp" #include "iceoryx_dust/posix_wrapper/named_pipe.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/unix_domain_socket.hpp" #include "iceoryx_platform/platform_settings.hpp" #include "iceoryx_posh/internal/runtime/ipc_interface_base.hpp" +#include "iox/message_queue.hpp" #include "iox/std_chrono_support.hpp" #include "test.hpp" From b779af592be14054c3076420667955f8a6e8866b Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 26 Oct 2023 00:48:09 +0200 Subject: [PATCH 02/12] iox-#1391 Move 'named_pipe' to 'posix/ipc' --- .../release-notes/iceoryx-unreleased.md | 2 +- iceoryx_dust/CMakeLists.txt | 4 +- .../ipc/include/iox}/named_pipe.hpp | 46 +++++++++---------- .../ipc/source}/named_pipe.cpp | 7 ++- .../internal/runtime/ipc_interface_base.hpp | 6 +-- .../source/runtime/ipc_interface_base.cpp | 4 +- .../test_runtime_ipc_interface.cpp | 2 +- 7 files changed, 34 insertions(+), 37 deletions(-) rename iceoryx_dust/{include/iceoryx_dust/posix_wrapper => posix/ipc/include/iox}/named_pipe.hpp (80%) rename iceoryx_dust/{source/posix_wrapper => posix/ipc/source}/named_pipe.cpp (99%) diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 2c0e379f79..147a14741a 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -1006,7 +1006,7 @@ #include "iceoryx_hoofs/posix_wrapper/named_pipe.hpp" // after - #include "iceoryx_dust/posix_wrapper/named_pipe.hpp" + #include "iox/named_pipe.hpp" ``` ```cpp diff --git a/iceoryx_dust/CMakeLists.txt b/iceoryx_dust/CMakeLists.txt index d5014da80a..3f6a43aa1e 100644 --- a/iceoryx_dust/CMakeLists.txt +++ b/iceoryx_dust/CMakeLists.txt @@ -71,9 +71,9 @@ iox_add_library( cli/source/option_definition.cpp cli/source/option_manager.cpp filesystem/source/file_reader.cpp - source/posix_wrapper/named_pipe.cpp - source/posix_wrapper/signal_watcher.cpp posix/ipc/source/message_queue.cpp + posix/ipc/source/named_pipe.cpp + source/posix_wrapper/signal_watcher.cpp ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/iceoryx_dust_deployment.hpp.in" diff --git a/iceoryx_dust/include/iceoryx_dust/posix_wrapper/named_pipe.hpp b/iceoryx_dust/posix/ipc/include/iox/named_pipe.hpp similarity index 80% rename from iceoryx_dust/include/iceoryx_dust/posix_wrapper/named_pipe.hpp rename to iceoryx_dust/posix/ipc/include/iox/named_pipe.hpp index 5286e2c083..c227a7360e 100644 --- a/iceoryx_dust/include/iceoryx_dust/posix_wrapper/named_pipe.hpp +++ b/iceoryx_dust/posix/ipc/include/iox/named_pipe.hpp @@ -14,8 +14,9 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_DUST_POSIX_WRAPPER_NAMED_PIPE_HPP -#define IOX_DUST_POSIX_WRAPPER_NAMED_PIPE_HPP + +#ifndef IOX_DUST_POSIX_IPC_NAMED_PIPE_HPP +#define IOX_DUST_POSIX_IPC_NAMED_PIPE_HPP #include "iceoryx_hoofs/concurrent/lockfree_queue.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/ipc_channel.hpp" @@ -34,8 +35,6 @@ namespace iox { -namespace posix -{ class NamedPipeBuilder; class NamedPipe @@ -71,51 +70,51 @@ class NamedPipe /// @brief removes a named pipe artifact from the system /// @return true if the artifact was removed, false when no artifact was found and /// IpcChannelError::INTERNAL_LOGIC_ERROR when shm_unlink failed - static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; + static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; /// @brief tries to send a message via the named pipe. if the pipe is full IpcChannelError::TIMEOUT is returned /// @return on failure an error which describes the failure - expected trySend(const std::string& message) const noexcept; + expected trySend(const std::string& message) const noexcept; /// @brief sends a message via the named pipe. if the pipe is full this call is blocking until the message could be /// delivered /// @param[in] message the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE /// @return success when message was sent otherwise an error which describes the failure - expected send(const std::string& message) const noexcept; + expected send(const std::string& message) const noexcept; /// @brief sends a message via the named pipe. /// @param[in] message the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE /// @param[in] timeout the timeout on how long this method should retry to send the message /// @return success when message was sent otherwise an error which describes the failure - expected timedSend(const std::string& message, - const units::Duration& timeout) const noexcept; + expected timedSend(const std::string& message, + const units::Duration& timeout) const noexcept; /// @brief tries to receive a message via the named pipe. if the pipe is empty IpcChannelError::TIMEOUT is returned /// @return on success a string containing the message, otherwise an error which describes the failure - expected tryReceive() const noexcept; + expected tryReceive() const noexcept; /// @brief receives a message via the named pipe. if the pipe is empty this call is blocking until a message was /// received /// @return on success a string containing the message, otherwise an error which describes the failure - expected receive() const noexcept; + expected receive() const noexcept; /// @brief receives a message via the named pipe. /// @param[in] timeout the timeout on how long this method should retry to receive a message /// @return on success a string containing the message, otherwise an error which describes the failure - expected timedReceive(const units::Duration& timeout) const noexcept; + expected timedReceive(const units::Duration& timeout) const noexcept; private: friend class NamedPipeBuilder; class NamedPipeData; - NamedPipe(SharedMemoryObject&& sharedMemory, NamedPipeData* data) noexcept; + NamedPipe(posix::SharedMemoryObject&& sharedMemory, NamedPipeData* data) noexcept; template static IpcChannelName_t mapToSharedMemoryName(const Prefix& p, const IpcChannelName_t& name) noexcept; /// @brief destroys an initialized named pipe. /// @return is always successful - expected destroy() noexcept; + expected destroy() noexcept; class NamedPipeData { @@ -128,10 +127,10 @@ class NamedPipe NamedPipeData& operator=(NamedPipeData&& rhs) = delete; ~NamedPipeData() = default; - UnnamedSemaphore& sendSemaphore() noexcept; - UnnamedSemaphore& receiveSemaphore() noexcept; + posix::UnnamedSemaphore& sendSemaphore() noexcept; + posix::UnnamedSemaphore& receiveSemaphore() noexcept; - expected initialize(const uint32_t maxMsgNumber) noexcept; + expected initialize(const uint32_t maxMsgNumber) noexcept; bool waitForInitialization() const noexcept; bool hasValidState() const noexcept; @@ -145,12 +144,12 @@ class NamedPipe static constexpr units::Duration WAIT_FOR_INIT_SLEEP_TIME = units::Duration::fromMilliseconds(1); std::atomic initializationGuard{INVALID_DATA}; - optional m_sendSemaphore; - optional m_receiveSemaphore; + optional m_sendSemaphore; + optional m_receiveSemaphore; }; private: - SharedMemoryObject m_sharedMemory; + posix::SharedMemoryObject m_sharedMemory; NamedPipeData* m_data = nullptr; }; @@ -160,7 +159,7 @@ class NamedPipeBuilder IOX_BUILDER_PARAMETER(IpcChannelName_t, name, "") /// @brief Defines how the named pipe is opened, i.e. as client or server - IOX_BUILDER_PARAMETER(IpcChannelSide, channelSide, IpcChannelSide::CLIENT) + IOX_BUILDER_PARAMETER(posix::IpcChannelSide, channelSide, posix::IpcChannelSide::CLIENT) /// @brief Defines the max message size of the named pipe IOX_BUILDER_PARAMETER(size_t, maxMsgSize, NamedPipe::MAX_MESSAGE_SIZE) @@ -171,10 +170,9 @@ class NamedPipeBuilder public: /// @brief create a named pipe /// @return On success a 'NamedPipe' is returned and on failure an 'IpcChannelError'. - expected create() const noexcept; + expected create() const noexcept; }; -} // namespace posix } // namespace iox -#endif +#endif // IOX_DUST_POSIX_IPC_NAMED_PIPE_HPP diff --git a/iceoryx_dust/source/posix_wrapper/named_pipe.cpp b/iceoryx_dust/posix/ipc/source/named_pipe.cpp similarity index 99% rename from iceoryx_dust/source/posix_wrapper/named_pipe.cpp rename to iceoryx_dust/posix/ipc/source/named_pipe.cpp index 710c437fee..20663e93d6 100644 --- a/iceoryx_dust/source/posix_wrapper/named_pipe.cpp +++ b/iceoryx_dust/posix/ipc/source/named_pipe.cpp @@ -15,7 +15,7 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/named_pipe.hpp" +#include "iox/named_pipe.hpp" #include "iox/bump_allocator.hpp" #include "iox/deadline_timer.hpp" #include "iox/filesystem.hpp" @@ -27,8 +27,8 @@ namespace iox { -namespace posix -{ +using namespace iox::posix; + /// NOLINTJUSTIFICATION see declaration in header /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) constexpr const char NamedPipe::NAMED_PIPE_PREFIX[]; @@ -361,5 +361,4 @@ bool NamedPipe::NamedPipeData::hasValidState() const noexcept return initializationGuard.load() == VALID_DATA; } -} // namespace posix } // namespace iox diff --git a/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp b/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp index b73d34bbd0..b0ce97c127 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp @@ -32,9 +32,9 @@ #include "iox/optional.hpp" #include "iox/relative_pointer.hpp" -#include "iceoryx_dust/posix_wrapper/named_pipe.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/unix_domain_socket.hpp" #include "iox/message_queue.hpp" +#include "iox/named_pipe.hpp" #include #include @@ -50,9 +50,9 @@ namespace iox namespace platform { #if defined(_WIN32) -using IoxIpcChannelType = iox::posix::NamedPipe; +using IoxIpcChannelType = iox::NamedPipe; #elif defined(__FREERTOS__) -using IoxIpcChannelType = iox::posix::NamedPipe; +using IoxIpcChannelType = iox::NamedPipe; #else using IoxIpcChannelType = iox::posix::UnixDomainSocket; #endif diff --git a/iceoryx_posh/source/runtime/ipc_interface_base.cpp b/iceoryx_posh/source/runtime/ipc_interface_base.cpp index 8485720ef7..7c505907ea 100644 --- a/iceoryx_posh/source/runtime/ipc_interface_base.cpp +++ b/iceoryx_posh/source/runtime/ipc_interface_base.cpp @@ -242,7 +242,7 @@ bool IpcInterface::ipcChannelMapsToFile() noexcept } template <> -bool IpcInterface::ipcChannelMapsToFile() noexcept +bool IpcInterface::ipcChannelMapsToFile() noexcept { return true; } @@ -263,7 +263,7 @@ void IpcInterface::cleanupOutdatedIpcChannel(const RuntimeName_t } template class IpcInterface; -template class IpcInterface; +template class IpcInterface; template class IpcInterface; } // namespace runtime diff --git a/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp b/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp index 271e8de44c..5ab99b5b22 100644 --- a/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp +++ b/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp @@ -15,11 +15,11 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/named_pipe.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/unix_domain_socket.hpp" #include "iceoryx_platform/platform_settings.hpp" #include "iceoryx_posh/internal/runtime/ipc_interface_base.hpp" #include "iox/message_queue.hpp" +#include "iox/named_pipe.hpp" #include "iox/std_chrono_support.hpp" #include "test.hpp" From 99945155f4a6f2b32103d28ad0c22996378e791b Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 26 Oct 2023 01:14:18 +0200 Subject: [PATCH 03/12] iox-#1391 Move 'signal_watcher' to 'posix/sync' --- iceoryx_dust/BUILD.bazel | 7 +++---- iceoryx_dust/CMakeLists.txt | 10 +++++----- .../sync/include/iox}/signal_watcher.hpp | 13 +++++-------- .../sync/source}/signal_watcher.cpp | 13 ++++++------- ...tcher.cpp => test_posix_sync_signal_watcher.cpp} | 3 ++- .../ice_callbacks_listener_as_class_member.cpp | 4 ++-- .../callbacks/ice_callbacks_publisher.cpp | 4 ++-- .../callbacks/ice_callbacks_subscriber.cpp | 6 +++--- .../complexdata/iox_publisher_complexdata.cpp | 4 ++-- .../complexdata/iox_publisher_vector.cpp | 4 ++-- .../complexdata/iox_subscriber_complexdata.cpp | 4 ++-- .../complexdata/iox_subscriber_vector.cpp | 4 ++-- .../ice_access_control/iox_display_app.cpp | 4 ++-- .../ice_access_control/iox_radar_app.cpp | 4 ++-- iceoryx_examples/icedelivery/iox_publisher.cpp | 4 ++-- .../icedelivery/iox_publisher_untyped.cpp | 4 ++-- iceoryx_examples/icedelivery/iox_subscriber.cpp | 4 ++-- .../icedelivery/iox_subscriber_untyped.cpp | 4 ++-- .../icediscovery/iox_discovery_monitor.cpp | 4 ++-- iceoryx_examples/icediscovery/iox_find_service.cpp | 4 ++-- iceoryx_examples/icediscovery/iox_offer_service.cpp | 4 ++-- .../icediscovery/iox_wait_for_service.cpp | 2 +- .../icehello/iox_publisher_helloworld.cpp | 4 ++-- .../icehello/iox_subscriber_helloworld.cpp | 4 ++-- .../iceoptions/iox_publisher_with_options.cpp | 6 +++--- .../iceoptions/iox_subscriber_with_options.cpp | 4 ++-- .../request_response/client_cxx_basic.cpp | 4 ++-- .../request_response/client_cxx_untyped.cpp | 4 ++-- .../request_response/client_cxx_waitset.cpp | 2 +- .../request_response/server_cxx_basic.cpp | 4 ++-- .../request_response/server_cxx_listener.cpp | 4 ++-- .../request_response/server_cxx_untyped.cpp | 4 ++-- iceoryx_examples/singleprocess/single_process.cpp | 8 ++++---- iceoryx_examples/user_header/publisher_cxx_api.cpp | 4 ++-- .../user_header/publisher_untyped_cxx_api.cpp | 4 ++-- iceoryx_examples/user_header/subscriber_cxx_api.cpp | 4 ++-- .../user_header/subscriber_untyped_cxx_api.cpp | 4 ++-- iceoryx_examples/waitset/ice_waitset_publisher.cpp | 4 ++-- .../include/iceoryx_posh/roudi/roudi_app.hpp | 2 +- .../source/roudi/application/iceoryx_roudi_app.cpp | 4 ++-- iceoryx_posh/source/roudi/application/roudi_app.cpp | 4 ++-- 41 files changed, 94 insertions(+), 98 deletions(-) rename iceoryx_dust/{include/iceoryx_dust/posix_wrapper => posix/sync/include/iox}/signal_watcher.hpp (91%) rename iceoryx_dust/{source/posix_wrapper => posix/sync/source}/signal_watcher.cpp (88%) rename iceoryx_dust/test/moduletests/{test_posix_signal_watcher.cpp => test_posix_sync_signal_watcher.cpp} (98%) diff --git a/iceoryx_dust/BUILD.bazel b/iceoryx_dust/BUILD.bazel index 5374b4573f..578ff24f80 100644 --- a/iceoryx_dust/BUILD.bazel +++ b/iceoryx_dust/BUILD.bazel @@ -33,19 +33,18 @@ cc_library( "cli/source/**/*.cpp", "filesystem/source/**/*.cpp", "posix/ipc/source/**/*.cpp", - "source/**/*.cpp", - "source/**/*.hpp", + "posix/sync/source/**/*.cpp", ]), - hdrs = glob(["include/**"]) + glob(["cli/**"]) + glob(["container/**"]) + glob(["filesystem/**"]) + glob(["memory/**"]) + glob(["utility/**"]) + glob(["posix/ipc/**"]) + glob(["vocabulary/**"]) + [ + hdrs = glob(["cli/**"]) + glob(["container/**"]) + glob(["filesystem/**"]) + glob(["memory/**"]) + glob(["utility/**"]) + glob(["posix/ipc/**"]) + glob(["posix/sync/**"]) + glob(["vocabulary/**"]) + [ ":iceoryx_dust_deployment_hpp", ], includes = [ "cli/include/", "container/include/", "filesystem/include/", - "include", "memory/include/", "posix/ipc/include/", + "posix/sync/include/", "utility/include/", "vocabulary/include/", ], diff --git a/iceoryx_dust/CMakeLists.txt b/iceoryx_dust/CMakeLists.txt index 3f6a43aa1e..f059e2a5ea 100644 --- a/iceoryx_dust/CMakeLists.txt +++ b/iceoryx_dust/CMakeLists.txt @@ -46,22 +46,22 @@ iox_add_library( PRIVATE_LIBS ${ICEORYX_SANITIZER_FLAGS} PRIVATE_LIBS_LINUX ${CODE_COVERAGE_LIBS} PUBLIC_LIBS iceoryx_hoofs::iceoryx_hoofs - BUILD_INTERFACE ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/cli/include + BUILD_INTERFACE ${PROJECT_SOURCE_DIR}/cli/include ${PROJECT_SOURCE_DIR}/container/include ${PROJECT_SOURCE_DIR}/filesystem/include ${PROJECT_SOURCE_DIR}/memory/include ${PROJECT_SOURCE_DIR}/posix/ipc/include + ${PROJECT_SOURCE_DIR}/posix/sync/include ${PROJECT_SOURCE_DIR}/utility/include ${PROJECT_SOURCE_DIR}/vocabulary/include ${CMAKE_BINARY_DIR}/generated/iceoryx_dust/include INSTALL_INTERFACE include/${PREFIX} - EXPORT_INCLUDE_DIRS include/ - cli/include/ + EXPORT_INCLUDE_DIRS cli/include/ container/include/ filesystem/include/ memory/include/ posix/ipc/include/ + posix/sync/include/ utility/include/ vocabulary/include/ FILES @@ -73,7 +73,7 @@ iox_add_library( filesystem/source/file_reader.cpp posix/ipc/source/message_queue.cpp posix/ipc/source/named_pipe.cpp - source/posix_wrapper/signal_watcher.cpp + posix/sync/source/signal_watcher.cpp ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/iceoryx_dust_deployment.hpp.in" diff --git a/iceoryx_dust/include/iceoryx_dust/posix_wrapper/signal_watcher.hpp b/iceoryx_dust/posix/sync/include/iox/signal_watcher.hpp similarity index 91% rename from iceoryx_dust/include/iceoryx_dust/posix_wrapper/signal_watcher.hpp rename to iceoryx_dust/posix/sync/include/iox/signal_watcher.hpp index 5afc615b2d..2923f94d5c 100644 --- a/iceoryx_dust/include/iceoryx_dust/posix_wrapper/signal_watcher.hpp +++ b/iceoryx_dust/posix/sync/include/iox/signal_watcher.hpp @@ -24,8 +24,6 @@ namespace iox { -namespace posix -{ /// @brief The SignalWatcher waits for SIGINT and SIGTERM. One can wait until the /// signal has occurred or ask the watcher if it has occurred. /// @code @@ -33,7 +31,7 @@ namespace posix /// #include /// void loopUntilTerminationRequested() /// { -/// while(!iox::posix::hasTerminationRequested()) +/// while(!iox::hasTerminationRequested()) /// { /// // your algorithm /// } @@ -42,7 +40,7 @@ namespace posix /// // another possibility is to block until SIGINT or SIGTERM has occurred /// void blockUntilCtrlC() { /// // your objects which spawn threads -/// iox::posix::waitForTerminationRequest(); +/// iox::waitForTerminationRequest(); /// } /// @endcode class SignalWatcher @@ -70,11 +68,11 @@ class SignalWatcher private: friend void internalSignalHandler(int) noexcept; mutable std::atomic m_numberOfWaiters{0U}; - mutable optional m_semaphore; + mutable optional m_semaphore; std::atomic_bool m_hasSignalOccurred{false}; - SignalGuard m_sigTermGuard; - SignalGuard m_sigIntGuard; + posix::SignalGuard m_sigTermGuard; + posix::SignalGuard m_sigIntGuard; }; /// @brief convenience function, calls SignalWatcher::getInstance().waitForSignal(); @@ -82,7 +80,6 @@ void waitForTerminationRequest() noexcept; /// @brief convenience function, calls SignalWatcher::getInstance().wasSignalTriggered(); bool hasTerminationRequested() noexcept; -} // namespace posix } // namespace iox #endif diff --git a/iceoryx_dust/source/posix_wrapper/signal_watcher.cpp b/iceoryx_dust/posix/sync/source/signal_watcher.cpp similarity index 88% rename from iceoryx_dust/source/posix_wrapper/signal_watcher.cpp rename to iceoryx_dust/posix/sync/source/signal_watcher.cpp index 9427e3a1b9..73a3d71251 100644 --- a/iceoryx_dust/source/posix_wrapper/signal_watcher.cpp +++ b/iceoryx_dust/posix/sync/source/signal_watcher.cpp @@ -13,13 +13,12 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" + +#include "iox/signal_watcher.hpp" #include "iceoryx_platform/unistd.hpp" namespace iox { -namespace posix -{ void internalSignalHandler(int) noexcept { auto& instance = SignalWatcher::getInstance(); @@ -44,10 +43,11 @@ void internalSignalHandler(int) noexcept SignalWatcher::SignalWatcher() noexcept : m_sigTermGuard( - registerSignalHandler(Signal::TERM, internalSignalHandler).expect("Unable to register Signal::TERM")) - , m_sigIntGuard(registerSignalHandler(Signal::INT, internalSignalHandler).expect("Unable to register Signal::INT")) + registerSignalHandler(posix::Signal::TERM, internalSignalHandler).expect("Unable to register Signal::TERM")) + , m_sigIntGuard( + registerSignalHandler(posix::Signal::INT, internalSignalHandler).expect("Unable to register Signal::INT")) { - UnnamedSemaphoreBuilder() + posix::UnnamedSemaphoreBuilder() .isInterProcessCapable(false) .create(m_semaphore) @@ -88,5 +88,4 @@ bool hasTerminationRequested() noexcept { return SignalWatcher::getInstance().wasSignalTriggered(); } -} // namespace posix } // namespace iox diff --git a/iceoryx_dust/test/moduletests/test_posix_signal_watcher.cpp b/iceoryx_dust/test/moduletests/test_posix_sync_signal_watcher.cpp similarity index 98% rename from iceoryx_dust/test/moduletests/test_posix_signal_watcher.cpp rename to iceoryx_dust/test/moduletests/test_posix_sync_signal_watcher.cpp index 89ea8d3eb2..bd543864f3 100644 --- a/iceoryx_dust/test/moduletests/test_posix_signal_watcher.cpp +++ b/iceoryx_dust/test/moduletests/test_posix_sync_signal_watcher.cpp @@ -14,15 +14,16 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_hoofs/testing/barrier.hpp" #include "iceoryx_hoofs/testing/watch_dog.hpp" +#include "iox/signal_watcher.hpp" #include "test.hpp" #include namespace { using namespace ::testing; +using namespace iox; using namespace iox::posix; class SignalWatcherTester : public SignalWatcher diff --git a/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp b/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp index d5048ab7a9..b5209fb006 100644 --- a/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp +++ b/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp @@ -14,12 +14,12 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/listener.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/popo/user_trigger.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iox/optional.hpp" +#include "iox/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -112,7 +112,7 @@ int main() CounterService counterService; - iox::posix::waitForTerminationRequest(); + iox::waitForTerminationRequest(); //! [init] return (EXIT_SUCCESS); diff --git a/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp b/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp index 8034ef6df9..29ba9d8085 100644 --- a/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp +++ b/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp @@ -14,9 +14,9 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -32,7 +32,7 @@ void sending() iox::popo::Publisher myPublisherLeft({"Radar", "FrontLeft", "Counter"}); iox::popo::Publisher myPublisherRight({"Radar", "FrontRight", "Counter"}); - for (uint32_t counter = 0U; !iox::posix::hasTerminationRequested(); ++counter) + for (uint32_t counter = 0U; !iox::hasTerminationRequested(); ++counter) { if (counter % 3 == 0) { diff --git a/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp b/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp index e16d147cde..e25cc58569 100644 --- a/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp +++ b/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp @@ -14,12 +14,12 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/listener.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/popo/user_trigger.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iox/optional.hpp" +#include "iox/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -91,7 +91,7 @@ int main() // send a heartbeat every 4 seconds //! [create heartbeat] std::thread heartbeatThread([&] { - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { heartbeat.trigger(); std::this_thread::sleep_for(std::chrono::seconds(4)); @@ -131,7 +131,7 @@ int main() // wait until someone presses CTRL+C //! [wait for sigterm] - iox::posix::waitForTerminationRequest(); + iox::waitForTerminationRequest(); //! [wait for sigterm] // optional detachEvent, but not required. diff --git a/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp b/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp index b0bc7d3cb9..8d515a4e41 100644 --- a/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp +++ b/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp @@ -16,9 +16,9 @@ #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" constexpr char APP_NAME[] = "iox-cpp-publisher-complexdata"; @@ -46,7 +46,7 @@ int main() uint64_t ct = 0; // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { ++ct; publisher.loan() diff --git a/iceoryx_examples/complexdata/iox_publisher_vector.cpp b/iceoryx_examples/complexdata/iox_publisher_vector.cpp index 8be0bad5ec..f1834ac29a 100644 --- a/iceoryx_examples/complexdata/iox_publisher_vector.cpp +++ b/iceoryx_examples/complexdata/iox_publisher_vector.cpp @@ -16,9 +16,9 @@ #include "iox/vector.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" constexpr char APP_NAME[] = "iox-cpp-publisher-vector"; @@ -34,7 +34,7 @@ int main() uint64_t ct = 0; // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { publisher.loan() .and_then([&](auto& sample) { diff --git a/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp b/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp index 5cefb1fea6..35f75181af 100644 --- a/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp +++ b/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp @@ -16,9 +16,9 @@ #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include "iox/string.hpp" constexpr char APP_NAME[] = "iox-cpp-subscriber-complexdata"; @@ -32,7 +32,7 @@ int main() iox::popo::Subscriber subscriber({"Group", "Instance", "ComplexDataTopic"}); // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { subscriber.take() .and_then([](auto& sample) { diff --git a/iceoryx_examples/complexdata/iox_subscriber_vector.cpp b/iceoryx_examples/complexdata/iox_subscriber_vector.cpp index c167e23835..90a8779c6b 100644 --- a/iceoryx_examples/complexdata/iox_subscriber_vector.cpp +++ b/iceoryx_examples/complexdata/iox_subscriber_vector.cpp @@ -14,9 +14,9 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include "iox/string.hpp" #include "iox/vector.hpp" @@ -31,7 +31,7 @@ int main() iox::popo::Subscriber> subscriber({"Radar", "FrontRight", "VectorData"}); // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { subscriber.take() .and_then([](auto& sample) { diff --git a/iceoryx_examples/ice_access_control/iox_display_app.cpp b/iceoryx_examples/ice_access_control/iox_display_app.cpp index 79cd6f7312..0ce9133e2b 100644 --- a/iceoryx_examples/ice_access_control/iox_display_app.cpp +++ b/iceoryx_examples/ice_access_control/iox_display_app.cpp @@ -16,10 +16,10 @@ #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include @@ -35,7 +35,7 @@ int main() iox::popo::Publisher publisher({"Radar", "HMI-Display", "Object"}); // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { auto takeResult = subscriber.take(); diff --git a/iceoryx_examples/ice_access_control/iox_radar_app.cpp b/iceoryx_examples/ice_access_control/iox_radar_app.cpp index 72b2f2fb6d..36c61ebaac 100644 --- a/iceoryx_examples/ice_access_control/iox_radar_app.cpp +++ b/iceoryx_examples/ice_access_control/iox_radar_app.cpp @@ -16,9 +16,9 @@ #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include @@ -32,7 +32,7 @@ int main() iox::popo::Publisher publisher({"Radar", "FrontLeft", "Object"}); double ct = 0.0; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { ++ct; diff --git a/iceoryx_examples/icedelivery/iox_publisher.cpp b/iceoryx_examples/icedelivery/iox_publisher.cpp index 6d32a94a2d..0b1ae0d7c4 100644 --- a/iceoryx_examples/icedelivery/iox_publisher.cpp +++ b/iceoryx_examples/icedelivery/iox_publisher.cpp @@ -20,8 +20,8 @@ //! [include publisher] #include "iceoryx_posh/popo/publisher.hpp" //! [include publisher] -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include @@ -41,7 +41,7 @@ int main() //! [create publisher] double ct = 0.0; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { ++ct; double sampleValue1 = ct + 89; diff --git a/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp b/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp index 735da37808..57ad1a46df 100644 --- a/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp +++ b/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp @@ -20,9 +20,9 @@ //! [include topic data] //! [includes] -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/untyped_publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [includes] #include @@ -39,7 +39,7 @@ int main() //! [create untyped publisher] double ct = 0.0; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { ++ct; diff --git a/iceoryx_examples/icedelivery/iox_subscriber.cpp b/iceoryx_examples/icedelivery/iox_subscriber.cpp index 8c79034f53..267b61bcb3 100644 --- a/iceoryx_examples/icedelivery/iox_subscriber.cpp +++ b/iceoryx_examples/icedelivery/iox_subscriber.cpp @@ -20,8 +20,8 @@ //! [include subscriber] #include "iceoryx_posh/popo/subscriber.hpp" //! [include subscriber] -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include @@ -37,7 +37,7 @@ int main() //! [create subscriber] // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { subscriber .take() diff --git a/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp b/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp index b667027406..a940c738aa 100644 --- a/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp +++ b/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp @@ -18,9 +18,9 @@ //! [includes] #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/untyped_subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [includes] #include @@ -38,7 +38,7 @@ int main() // run until interrupted by Ctrl-C //! [loop] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { subscriber .take() diff --git a/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp b/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp index 88fbbdb939..c182523884 100644 --- a/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp +++ b/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp @@ -18,8 +18,8 @@ #include "discovery_monitor.hpp" //! [include custom discovery] -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include @@ -76,7 +76,7 @@ int main() discovery.registerCallback(callback); //! [register callback] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { // here the app would run its functional code while the // service availability is monitored in the background diff --git a/iceoryx_examples/icediscovery/iox_find_service.cpp b/iceoryx_examples/icediscovery/iox_find_service.cpp index dea81f9550..7f3a42e463 100644 --- a/iceoryx_examples/icediscovery/iox_find_service.cpp +++ b/iceoryx_examples/icediscovery/iox_find_service.cpp @@ -14,8 +14,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [include ServiceDiscovery] #include "iceoryx_posh/runtime/service_discovery.hpp" //! [include ServiceDiscovery] @@ -39,7 +39,7 @@ int main() iox::runtime::ServiceDiscovery serviceDiscovery; //! [create ServiceDiscovery object] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { std::cout << "\n=========================================" << std::endl; diff --git a/iceoryx_examples/icediscovery/iox_offer_service.cpp b/iceoryx_examples/icediscovery/iox_offer_service.cpp index 0477015cd6..c05b5a9ac2 100644 --- a/iceoryx_examples/icediscovery/iox_offer_service.cpp +++ b/iceoryx_examples/icediscovery/iox_offer_service.cpp @@ -14,9 +14,9 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" constexpr char APP_NAME[] = "iox-offer-service"; @@ -37,7 +37,7 @@ int main() cameraPublishers.emplace_back(iox::capro::ServiceDescription{"Camera", "BackLeft", "Image"}); bool offer = false; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { if (offer) { diff --git a/iceoryx_examples/icediscovery/iox_wait_for_service.cpp b/iceoryx_examples/icediscovery/iox_wait_for_service.cpp index adde0acfa7..cbdf8e80e8 100644 --- a/iceoryx_examples/icediscovery/iox_wait_for_service.cpp +++ b/iceoryx_examples/icediscovery/iox_wait_for_service.cpp @@ -18,8 +18,8 @@ #include "discovery_blocking.hpp" //! [include custom discovery] -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include diff --git a/iceoryx_examples/icehello/iox_publisher_helloworld.cpp b/iceoryx_examples/icehello/iox_publisher_helloworld.cpp index 160f8d7d91..5394fba6ee 100644 --- a/iceoryx_examples/icehello/iox_publisher_helloworld.cpp +++ b/iceoryx_examples/icehello/iox_publisher_helloworld.cpp @@ -19,7 +19,7 @@ //! [include topic] //! [include sig watcher] -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" +#include "iox/signal_watcher.hpp" //! [include sig watcher] //! [include] @@ -43,7 +43,7 @@ int main() double ct = 0.0; //! [wait for term] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) //! [wait for term] { ++ct; diff --git a/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp b/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp index 68a6c87050..af2f4ba1e1 100644 --- a/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp +++ b/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp @@ -17,9 +17,9 @@ //! [include] #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [include] #include @@ -36,7 +36,7 @@ int main() //! [initialize subscriber] // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { //! [receive] auto takeResult = subscriber.take(); diff --git a/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp b/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp index 357f7692ee..8b898a3416 100644 --- a/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp +++ b/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp @@ -16,9 +16,9 @@ #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include @@ -63,7 +63,7 @@ int main() double ct = 0.0; std::thread publishData([&]() { - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { ++ct; @@ -76,7 +76,7 @@ int main() } }); - iox::posix::waitForTerminationRequest(); + iox::waitForTerminationRequest(); // this is optional, but since the iox::popo::ConsumerTooSlowPolicy::WAIT_FOR_CONSUMER option is used, // a slow subscriber might block the shutdown and this call unblocks the publisher diff --git a/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp b/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp index f33931b915..566e396514 100644 --- a/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp +++ b/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp @@ -16,9 +16,9 @@ #include "topic_data.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include @@ -76,7 +76,7 @@ int main() //! [subscribe] // run until interrupted by Ctrl-C - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { subscriber.take().and_then( [](auto& sample) { std::cout << APP_NAME << " got value: " << sample->x << std::endl; }); diff --git a/iceoryx_examples/request_response/client_cxx_basic.cpp b/iceoryx_examples/request_response/client_cxx_basic.cpp index 7cbbfb2ff3..7e5fd88ec7 100644 --- a/iceoryx_examples/request_response/client_cxx_basic.cpp +++ b/iceoryx_examples/request_response/client_cxx_basic.cpp @@ -17,9 +17,9 @@ //! [iceoryx includes] #include "request_and_response_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/client.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -40,7 +40,7 @@ int main() uint64_t fibonacciCurrent = 1; int64_t requestSequenceId = 0; int64_t expectedResponseSequenceId = requestSequenceId; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { //! [send request] client.loan() diff --git a/iceoryx_examples/request_response/client_cxx_untyped.cpp b/iceoryx_examples/request_response/client_cxx_untyped.cpp index 811d376d70..96793ae311 100644 --- a/iceoryx_examples/request_response/client_cxx_untyped.cpp +++ b/iceoryx_examples/request_response/client_cxx_untyped.cpp @@ -17,9 +17,9 @@ //! [iceoryx includes] #include "request_and_response_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/untyped_client.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -40,7 +40,7 @@ int main() uint64_t fibonacciCurrent = 1; int64_t requestSequenceId = 0; int64_t expectedResponseSequenceId = requestSequenceId; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { //! [send request] client.loan(sizeof(AddRequest), alignof(AddRequest)) diff --git a/iceoryx_examples/request_response/client_cxx_waitset.cpp b/iceoryx_examples/request_response/client_cxx_waitset.cpp index 1490699007..8088b4901f 100644 --- a/iceoryx_examples/request_response/client_cxx_waitset.cpp +++ b/iceoryx_examples/request_response/client_cxx_waitset.cpp @@ -17,11 +17,11 @@ //! [iceoryx includes] #include "request_and_response_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_hoofs/posix_wrapper/signal_handler.hpp" #include "iceoryx_posh/popo/client.hpp" #include "iceoryx_posh/popo/wait_set.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include diff --git a/iceoryx_examples/request_response/server_cxx_basic.cpp b/iceoryx_examples/request_response/server_cxx_basic.cpp index 02c5e600a6..3772ce86ef 100644 --- a/iceoryx_examples/request_response/server_cxx_basic.cpp +++ b/iceoryx_examples/request_response/server_cxx_basic.cpp @@ -17,9 +17,9 @@ //! [iceoryx includes] #include "request_and_response_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/server.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -36,7 +36,7 @@ int main() //! [create server] //! [process requests in a loop] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { //! [take request] server.take().and_then([&](const auto& request) { diff --git a/iceoryx_examples/request_response/server_cxx_listener.cpp b/iceoryx_examples/request_response/server_cxx_listener.cpp index 45842cba3e..62ca9d492f 100644 --- a/iceoryx_examples/request_response/server_cxx_listener.cpp +++ b/iceoryx_examples/request_response/server_cxx_listener.cpp @@ -17,10 +17,10 @@ //! [iceoryx includes] #include "request_and_response_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/listener.hpp" #include "iceoryx_posh/popo/server.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -76,7 +76,7 @@ int main() //! [attach listener] //! [wait for termination] - iox::posix::waitForTerminationRequest(); + iox::waitForTerminationRequest(); //! [wait for termination] //! [cleanup] diff --git a/iceoryx_examples/request_response/server_cxx_untyped.cpp b/iceoryx_examples/request_response/server_cxx_untyped.cpp index 3fd6a6debb..651a30a659 100644 --- a/iceoryx_examples/request_response/server_cxx_untyped.cpp +++ b/iceoryx_examples/request_response/server_cxx_untyped.cpp @@ -17,9 +17,9 @@ //! [iceoryx includes] #include "request_and_response_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/untyped_server.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -36,7 +36,7 @@ int main() //! [create server] //! [process requests in a loop] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { //! [take request] server.take().and_then([&](auto& requestPayload) { diff --git a/iceoryx_examples/singleprocess/single_process.cpp b/iceoryx_examples/singleprocess/single_process.cpp index 0a338bb641..f4ae89f5fb 100644 --- a/iceoryx_examples/singleprocess/single_process.cpp +++ b/iceoryx_examples/singleprocess/single_process.cpp @@ -15,7 +15,6 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/iceoryx_posh_config.hpp" #include "iceoryx_posh/iceoryx_posh_types.hpp" #include "iceoryx_posh/internal/roudi/roudi.hpp" @@ -25,6 +24,7 @@ #include "iceoryx_posh/runtime/posh_runtime_single_process.hpp" #include "iox/detail/convert.hpp" #include "iox/logging.hpp" +#include "iox/signal_watcher.hpp" #include #include @@ -59,7 +59,7 @@ void publisher() //! [send] uint64_t counter{0}; constexpr const char GREEN_RIGHT_ARROW[] = "\033[32m->\033[m "; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { publisher.loan().and_then([&](auto& sample) { sample->counter = counter++; @@ -83,7 +83,7 @@ void subscriber() //! [receive] constexpr const char ORANGE_LEFT_ARROW[] = "\033[33m<-\033[m "; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { if (iox::SubscribeState::SUBSCRIBED == subscriber.getSubscriptionState()) { @@ -136,7 +136,7 @@ int main() //! [run] std::thread publisherThread(publisher), subscriberThread(subscriber); - iox::posix::waitForTerminationRequest(); + iox::waitForTerminationRequest(); publisherThread.join(); subscriberThread.join(); diff --git a/iceoryx_examples/user_header/publisher_cxx_api.cpp b/iceoryx_examples/user_header/publisher_cxx_api.cpp index e3dfb7b728..78599083af 100644 --- a/iceoryx_examples/user_header/publisher_cxx_api.cpp +++ b/iceoryx_examples/user_header/publisher_cxx_api.cpp @@ -17,9 +17,9 @@ //! [iceoryx includes] #include "user_header_and_payload_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -40,7 +40,7 @@ int main() uint64_t timestamp = 42; uint64_t fibonacciLast = 0; uint64_t fibonacciCurrent = 1; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { auto fibonacciNext = fibonacciCurrent + fibonacciLast; fibonacciLast = fibonacciCurrent; diff --git a/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp b/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp index c52d7cc3a7..02c4116daf 100644 --- a/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp +++ b/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp @@ -17,7 +17,7 @@ //! [iceoryx includes] #include "user_header_and_payload_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" +#include "iox/signal_watcher.hpp" //! [include differs from typed C++ API] #include "iceoryx_posh/popo/untyped_publisher.hpp" //! [include differs from typed C++ API] @@ -42,7 +42,7 @@ int main() uint64_t timestamp = 73; uint64_t fibonacciLast = 0; uint64_t fibonacciCurrent = 1; - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { auto fibonacciNext = fibonacciCurrent + fibonacciLast; fibonacciLast = fibonacciCurrent; diff --git a/iceoryx_examples/user_header/subscriber_cxx_api.cpp b/iceoryx_examples/user_header/subscriber_cxx_api.cpp index 4737620610..74bb00d22b 100644 --- a/iceoryx_examples/user_header/subscriber_cxx_api.cpp +++ b/iceoryx_examples/user_header/subscriber_cxx_api.cpp @@ -17,9 +17,9 @@ //! [iceoryx includes] #include "user_header_and_payload_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -37,7 +37,7 @@ int main() //! [create subscriber] //! [poll subscriber for samples in a loop] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { //! [take sample] subscriber.take().and_then([&](auto& sample) { diff --git a/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp b/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp index ee176ce48a..9272a3671f 100644 --- a/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp +++ b/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp @@ -17,9 +17,9 @@ //! [iceoryx includes] #include "user_header_and_payload_types.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/untyped_subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" //! [iceoryx includes] #include @@ -37,7 +37,7 @@ int main() //! [create subscriber] //! [poll subscriber for samples in a loop] - while (!iox::posix::hasTerminationRequested()) + while (!iox::hasTerminationRequested()) { //! [take chunk] subscriber.take().and_then([&](auto& userPayload) { diff --git a/iceoryx_examples/waitset/ice_waitset_publisher.cpp b/iceoryx_examples/waitset/ice_waitset_publisher.cpp index 9a692d41db..4fcc03ac35 100644 --- a/iceoryx_examples/waitset/ice_waitset_publisher.cpp +++ b/iceoryx_examples/waitset/ice_waitset_publisher.cpp @@ -14,9 +14,9 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" +#include "iox/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -27,7 +27,7 @@ void sending() iox::runtime::PoshRuntime::initRuntime("iox-cpp-publisher-waitset"); iox::popo::Publisher myPublisher({"Radar", "FrontLeft", "Counter"}); - for (uint32_t counter = 0U; !iox::posix::hasTerminationRequested(); ++counter) + for (uint32_t counter = 0U; !iox::hasTerminationRequested(); ++counter) { myPublisher.publishCopyOf(CounterTopic{counter}) .and_then([&] { std::cout << "Sending: " << counter << std::endl; }) diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp index f7b27751a8..f309e8af47 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp @@ -48,7 +48,7 @@ class RouDiApp protected: /// @brief waits for the next signal to RouDi daemon [[deprecated("in 3.0, removed in 4.0, use iox::posix::waitForTerminationRequest() from " - "'iceoryx_dust/posix_wrapper/signal_watcher.hpp'")]] bool + "'iox/signal_watcher.hpp'")]] bool waitForSignal() noexcept; iox::log::LogLevel m_logLevel{iox::log::LogLevel::WARN}; diff --git a/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp b/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp index 19cd9d183f..55d4a7a2c3 100644 --- a/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp +++ b/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp @@ -17,11 +17,11 @@ #include "iceoryx_posh/roudi/iceoryx_roudi_app.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_posh/internal/roudi/roudi.hpp" #include "iceoryx_posh/roudi/iceoryx_roudi_components.hpp" #include "iox/optional.hpp" #include "iox/scoped_static.hpp" +#include "iox/signal_watcher.hpp" namespace iox { @@ -50,7 +50,7 @@ uint8_t IceOryxRouDiApp::run() noexcept m_compatibilityCheckLevel, m_processKillDelay, m_processTeminationDelay}); - iox::posix::waitForTerminationRequest(); + iox::waitForTerminationRequest(); } return EXIT_SUCCESS; } diff --git a/iceoryx_posh/source/roudi/application/roudi_app.cpp b/iceoryx_posh/source/roudi/application/roudi_app.cpp index a7ed7fff71..7a3987720e 100644 --- a/iceoryx_posh/source/roudi/application/roudi_app.cpp +++ b/iceoryx_posh/source/roudi/application/roudi_app.cpp @@ -17,7 +17,6 @@ #include "iceoryx_posh/roudi/roudi_app.hpp" -#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" #include "iceoryx_platform/getopt.hpp" #include "iceoryx_platform/resource.hpp" #include "iceoryx_platform/semaphore.hpp" @@ -26,6 +25,7 @@ #include "iceoryx_posh/roudi/cmd_line_args.hpp" #include "iox/logging.hpp" #include "iox/optional.hpp" +#include "iox/signal_watcher.hpp" namespace iox { @@ -79,7 +79,7 @@ bool RouDiApp::checkAndOptimizeConfig(const RouDiConfig_t& config) noexcept bool RouDiApp::waitForSignal() noexcept { - iox::posix::waitForTerminationRequest(); + iox::waitForTerminationRequest(); return true; } From ccd74bb7246c667e7c22d6b9780c037609f206d6 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 26 Oct 2023 03:31:03 +0200 Subject: [PATCH 04/12] iox-#1391 Fix bazel build --- iceoryx_dust/BUILD.bazel | 3 ++- iceoryx_hoofs/BUILD.bazel | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/iceoryx_dust/BUILD.bazel b/iceoryx_dust/BUILD.bazel index 578ff24f80..fd6f6a8699 100644 --- a/iceoryx_dust/BUILD.bazel +++ b/iceoryx_dust/BUILD.bazel @@ -20,7 +20,7 @@ load("//bazel:configure_file.bzl", "configure_file") configure_file( name = "iceoryx_dust_deployment_hpp", src = "cmake/iceoryx_dust_deployment.hpp.in", - out = "include/iox/iceoryx_dust_deployment.hpp", + out = "generated/include/iox/iceoryx_dust_deployment.hpp", config = { "IOX_MAX_NAMED_PIPE_MESSAGE_SIZE": "4096", "IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES": "10", @@ -42,6 +42,7 @@ cc_library( "cli/include/", "container/include/", "filesystem/include/", + "generated/include/", "memory/include/", "posix/ipc/include/", "posix/sync/include/", diff --git a/iceoryx_hoofs/BUILD.bazel b/iceoryx_hoofs/BUILD.bazel index 9de62f34d6..fb1d1d2bbf 100644 --- a/iceoryx_hoofs/BUILD.bazel +++ b/iceoryx_hoofs/BUILD.bazel @@ -21,7 +21,7 @@ load("//bazel:configure_version.bzl", "configure_version") configure_file( name = "iceoryx_hoofs_deployment_hpp", src = "cmake/iceoryx_hoofs_deployment.hpp.in", - out = "include/iox/iceoryx_hoofs_deployment.hpp", + out = "generated/include/iox/iceoryx_hoofs_deployment.hpp", config = { # FIXME: for values see "iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake" ... for now some nice defaults "IOX_MINIMAL_LOG_LEVEL": "TRACE", @@ -31,7 +31,7 @@ configure_file( configure_version( name = "iceoryx_versions_h", src = "cmake/iceoryx_versions.h.in", - out = "include/iceoryx_versions.h", + out = "generated/include/iceoryx_versions.h", version_from = "//:VERSION", ) @@ -62,6 +62,7 @@ cc_library( "design/include", "filesystem/include", "functional/include", + "generated/include", "include/", "legacy/include/", "memory/include/", From b85eebe8b071d6bab0be74ff1e44d50f6f63e3bb Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 26 Oct 2023 15:11:09 +0200 Subject: [PATCH 05/12] iox-#1391 Fix Windows build --- iceoryx_dust/posix/ipc/source/message_queue.cpp | 3 ++- iceoryx_dust/posix/ipc/source/named_pipe.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/iceoryx_dust/posix/ipc/source/message_queue.cpp b/iceoryx_dust/posix/ipc/source/message_queue.cpp index 5cae8a7b6e..00a4f1d607 100644 --- a/iceoryx_dust/posix/ipc/source/message_queue.cpp +++ b/iceoryx_dust/posix/ipc/source/message_queue.cpp @@ -28,7 +28,8 @@ namespace iox { -using namespace iox::posix; +using posix::IpcChannelError; +using posix::IpcChannelSide; expected MessageQueueBuilder::create() const noexcept { diff --git a/iceoryx_dust/posix/ipc/source/named_pipe.cpp b/iceoryx_dust/posix/ipc/source/named_pipe.cpp index 20663e93d6..87fc817c91 100644 --- a/iceoryx_dust/posix/ipc/source/named_pipe.cpp +++ b/iceoryx_dust/posix/ipc/source/named_pipe.cpp @@ -27,7 +27,16 @@ namespace iox { -using namespace iox::posix; +using posix::AccessMode; +using posix::IpcChannelError; +using posix::IpcChannelSide; +using posix::OpenMode; +using posix::SemaphoreWaitState; +using posix::SharedMemory; +using posix::SharedMemoryObject; +using posix::SharedMemoryObjectBuilder; +using posix::UnnamedSemaphore; +using posix::UnnamedSemaphoreBuilder; /// NOLINTJUSTIFICATION see declaration in header /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) From 7f2d939a12b89c03663621fbe9db115c03ffe5da Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Mon, 6 Nov 2023 16:35:02 +0100 Subject: [PATCH 06/12] iox-#1391 Fix race in PortUser_IntegrationTest --- .../test_popo_port_user_building_blocks.cpp | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp index 44c7a08e75..a0176e15b1 100644 --- a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp +++ b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp @@ -111,9 +111,9 @@ class PortUser_IntegrationTest : public Test Watchdog m_deadlockWatchdog{DEADLOCK_TIMEOUT}; - uint64_t m_receiveCounter{0U}; + std::atomic m_receiveCounter{0U}; std::atomic m_sendCounter{0U}; - std::atomic m_publisherRunFinished{0U}; + std::atomic m_publisherRunFinished{false}; // Memory objects iox::BumpAllocator m_memoryAllocator{g_memory, MEMORY_SIZE}; @@ -178,9 +178,7 @@ class PortUser_IntegrationTest : public Test } template - void subscriberThread(uint32_t numberOfPublishers, - SubscriberPortType& subscriberPortRouDi, - SubscriberPortUser& subscriberPortUser) + void subscriberThread(SubscriberPortType& subscriberPortRouDi, SubscriberPortUser& subscriberPortUser) { bool finished{false}; @@ -213,17 +211,14 @@ class PortUser_IntegrationTest : public Test // Try to receive chunk subscriberPortUser.tryGetChunk() .and_then([&](auto& chunkHeader) { - m_receiveCounter++; + m_receiveCounter.fetch_add(1, std::memory_order_relaxed); subscriberPortUser.releaseChunk(chunkHeader); }) .or_else([&](auto& result) { if (result == ChunkReceiveResult::NO_CHUNK_AVAILABLE) { // Nothing received -> check if publisher(s) still running - if (m_publisherRunFinished.load(std::memory_order_relaxed) == numberOfPublishers) - { - finished = true; - } + finished = m_publisherRunFinished.load(std::memory_order_relaxed); } else { @@ -298,8 +293,17 @@ class PortUser_IntegrationTest : public Test } // Subscriber is ready to receive -> start sending samples - for (size_t i = 0U; i < ITERATIONS; i++) + size_t i = 0U; + while (i < ITERATIONS) { + // slow down to ensure there is no overflow + auto receiveCounter = m_receiveCounter.load(std::memory_order_relaxed); + auto sendCounter = m_sendCounter.load(std::memory_order_seq_cst); + if (sendCounter - receiveCounter > 100) + { + std::this_thread::yield(); + continue; + } publisherPortUser .tryAllocateChunk(sizeof(DummySample), alignof(DummySample), @@ -310,56 +314,54 @@ class PortUser_IntegrationTest : public Test new (sample) DummySample(); static_cast(sample)->m_dummy = i; publisherPortUser.sendChunk(chunkHeader); - m_sendCounter++; + m_sendCounter.fetch_add(1, std::memory_order_relaxed); }) .or_else([](auto error) { // Errors shall never occur GTEST_FAIL() << "Error in tryAllocateChunk(): " << static_cast(error); }); + ++i; + /// Add some jitter to make thread breathe - std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 4)); + std::this_thread::sleep_for(std::chrono::microseconds(100 + rand() % 50)); } - - // Signal the subscriber thread we're done - m_publisherRunFinished++; } }; -TIMING_TEST_F(PortUser_IntegrationTest, SingleProducer, Repeat(5), [&] { +TEST_F(PortUser_IntegrationTest, SingleProducer) +{ ::testing::Test::RecordProperty("TEST_ID", "bb62ac02-2b7d-4d1c-8699-9f5ba4d9bd5a"); - std::thread subscribingThread([this] { - constexpr uint32_t NUMBER_OF_PUBLISHERS_SINGLE_PRODUCER = 1U; - subscriberThread(NUMBER_OF_PUBLISHERS_SINGLE_PRODUCER, - m_subscriberPortRouDiSingleProducer, - m_subscriberPortUserSingleProducer); - }); + std::thread subscribingThread( + [this] { subscriberThread(m_subscriberPortRouDiSingleProducer, m_subscriberPortUserSingleProducer); }); std::thread publishingThread([this] { constexpr uint32_t INDEX_OF_PUBLISHER_SINGLE_PRODUCER = 0U; publisherThread( INDEX_OF_PUBLISHER_SINGLE_PRODUCER, m_publisherPortRouDiVector.front(), m_publisherPortUserVector.front()); }); - if (subscribingThread.joinable()) + if (publishingThread.joinable()) { - subscribingThread.join(); + publishingThread.join(); } + m_publisherRunFinished.store(true, std::memory_order_relaxed); - if (publishingThread.joinable()) + if (subscribingThread.joinable()) { - publishingThread.join(); + subscribingThread.join(); } - TIMING_TEST_EXPECT_TRUE(m_sendCounter.load(std::memory_order_relaxed) == m_receiveCounter); - TIMING_TEST_EXPECT_FALSE(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall()); -}) + EXPECT_THAT(m_receiveCounter.load(std::memory_order_relaxed), Eq(m_sendCounter.load(std::memory_order_relaxed))); + EXPECT_FALSE(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall()); +} -TIMING_TEST_F(PortUser_IntegrationTest, MultiProducer, Repeat(5), [&] { +TEST_F(PortUser_IntegrationTest, MultiProducer) +{ ::testing::Test::RecordProperty("TEST_ID", "d27279d3-26c0-4489-9208-bd361120525a"); - std::thread subscribingThread([this] { - subscriberThread(NUMBER_OF_PUBLISHERS, m_subscriberPortRouDiMultiProducer, m_subscriberPortUserMultiProducer); - }); + + std::thread subscribingThread( + [this] { subscriberThread(m_subscriberPortRouDiMultiProducer, m_subscriberPortUserMultiProducer); }); for (uint32_t i = 0U; i < NUMBER_OF_PUBLISHERS; i++) { @@ -367,11 +369,6 @@ TIMING_TEST_F(PortUser_IntegrationTest, MultiProducer, Repeat(5), [&] { [i, this] { publisherThread(i, m_publisherPortRouDiVector[i], m_publisherPortUserVector[i]); }); } - if (subscribingThread.joinable()) - { - subscribingThread.join(); - } - for (uint32_t i = 0U; i < NUMBER_OF_PUBLISHERS; i++) { if (m_publisherThreadVector[i].joinable()) @@ -379,9 +376,15 @@ TIMING_TEST_F(PortUser_IntegrationTest, MultiProducer, Repeat(5), [&] { m_publisherThreadVector[i].join(); } } + m_publisherRunFinished.store(true, std::memory_order_relaxed); + + if (subscribingThread.joinable()) + { + subscribingThread.join(); + } - TIMING_TEST_EXPECT_TRUE(m_sendCounter.load(std::memory_order_relaxed) == m_receiveCounter); - TIMING_TEST_EXPECT_FALSE(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall()); -}) + EXPECT_THAT(m_receiveCounter.load(std::memory_order_relaxed), Eq(m_sendCounter.load(std::memory_order_relaxed))); + EXPECT_FALSE(PortUser_IntegrationTest::m_subscriberPortUserMultiProducer.hasLostChunksSinceLastCall()); +} } // namespace From bfa9a9ef15a7b900ddf8eef39987fe9adc4f8b81 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 9 Nov 2023 17:02:34 +0100 Subject: [PATCH 07/12] iox-#1391 Use IOX_EXPECTS_WITH_MSG where appropriate --- iceoryx_binding_c/source/c_runtime.cpp | 6 +++--- .../container/include/iox/detail/forward_list.inl | 10 +++++----- .../container/include/iox/detail/list.inl | 14 +++++++------- iceoryx_hoofs/source/concurrent/loffli.cpp | 8 ++++---- .../roudi_env/source/runtime_test_interface.cpp | 6 +++--- .../source/popo/ports/client_port_roudi.cpp | 2 +- .../testing/mocks/posh_runtime_mock.hpp | 13 +++++++------ 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/iceoryx_binding_c/source/c_runtime.cpp b/iceoryx_binding_c/source/c_runtime.cpp index 56174e846b..99a2a1ab47 100644 --- a/iceoryx_binding_c/source/c_runtime.cpp +++ b/iceoryx_binding_c/source/c_runtime.cpp @@ -27,9 +27,9 @@ extern "C" { void iox_runtime_init(const char* const name) { - IOX_EXPECTS(name != nullptr && "Runtime name is a nullptr!"); - IOX_EXPECTS(strnlen(name, iox::MAX_RUNTIME_NAME_LENGTH + 1) <= MAX_RUNTIME_NAME_LENGTH - && "Runtime name has more than 100 characters!"); + IOX_EXPECTS_WITH_MSG(name != nullptr, "Runtime name is a nullptr!"); + IOX_EXPECTS_WITH_MSG(strnlen(name, iox::MAX_RUNTIME_NAME_LENGTH + 1) <= MAX_RUNTIME_NAME_LENGTH, + "Runtime name has more than 100 characters!"); PoshRuntime::initRuntime(RuntimeName_t(iox::TruncateToCapacity, name)); } diff --git a/iceoryx_dust/container/include/iox/detail/forward_list.inl b/iceoryx_dust/container/include/iox/detail/forward_list.inl index a92807e42a..1da79860ea 100644 --- a/iceoryx_dust/container/include/iox/detail/forward_list.inl +++ b/iceoryx_dust/container/include/iox/detail/forward_list.inl @@ -329,7 +329,7 @@ template inline T& forward_list::front() noexcept { auto iter = begin(); - IOX_EXPECTS(isValidElementIdx(iter.m_iterListNodeIdx) && "Invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx(iter.m_iterListNodeIdx), "Invalid list element"); return *iter; } @@ -337,7 +337,7 @@ template inline const T& forward_list::front() const noexcept { auto citer = cbegin(); - IOX_EXPECTS(isValidElementIdx(citer.m_iterListNodeIdx) && "Invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx(citer.m_iterListNodeIdx), "Invalid list element"); return *citer; } @@ -556,7 +556,7 @@ inline void forward_list::setNextIdx(const size_type idx, const siz template inline const T* forward_list::getDataPtrFromIdx(const size_type idx) const noexcept { - IOX_EXPECTS(isValidElementIdx(idx) && "Invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx(idx), "Invalid list element"); // safe since m_data entries are aligned to T // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) @@ -597,14 +597,14 @@ inline bool forward_list::isInvalidIterator(const const_iterator& i { // iterator's member m_iterListNodeIdx and nextIndex are not checked here to be <= END_INDEX as this // should (can) never happen though normal list operations. - IOX_EXPECTS(!isInvalidElement(iter.m_iterListNodeIdx) && "invalidated iterator"); + IOX_EXPECTS_WITH_MSG(!isInvalidElement(iter.m_iterListNodeIdx), "invalidated iterator"); return false; } template inline bool forward_list::isInvalidIterOrDifferentLists(const const_iterator& iter) const noexcept { - IOX_EXPECTS((this == iter.m_list) && "iterator of other list can't be used"); + IOX_EXPECTS_WITH_MSG((this == iter.m_list), "iterator of other list can't be used"); return isInvalidIterator(iter); } diff --git a/iceoryx_hoofs/container/include/iox/detail/list.inl b/iceoryx_hoofs/container/include/iox/detail/list.inl index 8c51c82d76..a46db49325 100644 --- a/iceoryx_hoofs/container/include/iox/detail/list.inl +++ b/iceoryx_hoofs/container/include/iox/detail/list.inl @@ -330,7 +330,7 @@ template inline T& list::front() noexcept { auto iter = begin(); - IOX_EXPECTS(isValidElementIdx(iter.m_iterListNodeIdx) && "invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx(iter.m_iterListNodeIdx), "invalid list element"); return *iter; } @@ -338,7 +338,7 @@ template inline const T& list::front() const noexcept { auto citer = cbegin(); - IOX_EXPECTS(isValidElementIdx(citer.m_iterListNodeIdx) && "invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx(citer.m_iterListNodeIdx), "invalid list element"); return *citer; } @@ -346,7 +346,7 @@ template inline T& list::back() noexcept { auto iter = end(); - IOX_EXPECTS(isValidElementIdx((--iter).m_iterListNodeIdx) && "invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx((--iter).m_iterListNodeIdx), "invalid list element"); return *iter; } @@ -354,7 +354,7 @@ template inline const T& list::back() const noexcept { auto citer = cend(); - IOX_EXPECTS(isValidElementIdx((--citer).m_iterListNodeIdx) && "invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx((--citer).m_iterListNodeIdx), "invalid list element"); return *citer; } @@ -653,7 +653,7 @@ inline void list::setNextIdx(const size_type idx, const size_type n template inline const T* list::getDataPtrFromIdx(const size_type idx) const noexcept { - IOX_EXPECTS(isValidElementIdx(idx) && "invalid list element"); + IOX_EXPECTS_WITH_MSG(isValidElementIdx(idx), "invalid list element"); /// @NOLINTJUSTIFICATION provide type safe access to the encapsulated untyped m_data array /// @NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) @@ -684,14 +684,14 @@ inline bool list::isInvalidIterator(const const_iterator& iter) con // freeList / invalid elements will have the prevIdx set to INVALID_INDEX // additional check on e.g. nextIdx or m_iterListNodeIdx ( inline bool list::isInvalidIterOrDifferentLists(const const_iterator& iter) const noexcept { - IOX_EXPECTS((this == iter.m_list) && "iterator of other list can't be used"); + IOX_EXPECTS_WITH_MSG((this == iter.m_list), "iterator of other list can't be used"); return isInvalidIterator(iter); } diff --git a/iceoryx_hoofs/source/concurrent/loffli.cpp b/iceoryx_hoofs/source/concurrent/loffli.cpp index 30b2fda26a..b0128cb0dd 100644 --- a/iceoryx_hoofs/source/concurrent/loffli.cpp +++ b/iceoryx_hoofs/source/concurrent/loffli.cpp @@ -25,11 +25,11 @@ namespace concurrent { void LoFFLi::init(not_null freeIndicesMemory, const uint32_t capacity) noexcept { - IOX_EXPECTS(capacity > 0 && "A capacity of 0 is not supported!"); + IOX_EXPECTS_WITH_MSG(capacity > 0, "A capacity of 0 is not supported!"); constexpr uint32_t INTERNALLY_RESERVED_INDICES{1U}; - IOX_EXPECTS(capacity < (std::numeric_limits::max() - INTERNALLY_RESERVED_INDICES) - && "Requested capacity exceeds limits!"); - IOX_EXPECTS(m_head.is_lock_free() && "std::atomic must be lock-free!"); + IOX_EXPECTS_WITH_MSG(capacity < (std::numeric_limits::max() - INTERNALLY_RESERVED_INDICES), + "Requested capacity exceeds limits!"); + IOX_EXPECTS_WITH_MSG(m_head.is_lock_free(), "std::atomic must be lock-free!"); m_nextFreeIndex = freeIndicesMemory; m_size = capacity; diff --git a/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp b/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp index 84dfd87ca6..de0845c1de 100644 --- a/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp +++ b/iceoryx_posh/roudi_env/source/runtime_test_interface.cpp @@ -36,9 +36,9 @@ RuntimeTestInterface::RuntimeTestInterface() { std::lock_guard lock(RuntimeTestInterface::s_runtimeAccessMutex); - IOX_EXPECTS(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory - && "The RuntimeTestInterface can only be used in combination with the " - "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); + IOX_EXPECTS_WITH_MSG(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory, + "The RuntimeTestInterface can only be used in combination with the " + "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); PoshRuntime::setRuntimeFactory(RuntimeTestInterface::runtimeFactoryGetInstance); } diff --git a/iceoryx_posh/source/popo/ports/client_port_roudi.cpp b/iceoryx_posh/source/popo/ports/client_port_roudi.cpp index e7677bedd7..dc3d0e76bd 100644 --- a/iceoryx_posh/source/popo/ports/client_port_roudi.cpp +++ b/iceoryx_posh/source/popo/ports/client_port_roudi.cpp @@ -150,7 +150,7 @@ ClientPortRouDi::handleCaProMessageForStateConnectRequested(const capro::CaproMe switch (caProMessage.m_type) { case capro::CaproMessageType::ACK: - IOX_EXPECTS(caProMessage.m_chunkQueueData != nullptr && "Invalid request queue passed to client"); + IOX_EXPECTS_WITH_MSG(caProMessage.m_chunkQueueData != nullptr, "Invalid request queue passed to client"); IOX_EXPECTS(!m_chunkSender .tryAddQueue(static_cast(caProMessage.m_chunkQueueData), caProMessage.m_historyCapacity) diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp index 92c919de2d..889147f84a 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/posh_runtime_mock.hpp @@ -28,10 +28,10 @@ class PoshRuntimeMock : public iox::runtime::PoshRuntime static std::unique_ptr create(const iox::RuntimeName_t& name) { auto& runtime = mockRuntime(); - IOX_EXPECTS(!runtime.has_value() && "Using multiple PoshRuntimeMock in parallel is not supported!"); - IOX_EXPECTS(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory - && "The PoshRuntimeMock can only be used in combination with the " - "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); + IOX_EXPECTS_WITH_MSG(!runtime.has_value(), "Using multiple PoshRuntimeMock in parallel is not supported!"); + IOX_EXPECTS_WITH_MSG(PoshRuntime::getRuntimeFactory() == PoshRuntime::defaultRuntimeFactory, + "The PoshRuntimeMock can only be used in combination with the " + "PoshRuntime::defaultRuntimeFactory! Someone else already switched the factory!"); runtime = new PoshRuntimeMock(name); PoshRuntime::setRuntimeFactory(mockRuntimeFactory); @@ -95,8 +95,9 @@ class PoshRuntimeMock : public iox::runtime::PoshRuntime static PoshRuntime& mockRuntimeFactory(iox::optional name) noexcept { auto& runtime = mockRuntime(); - IOX_EXPECTS(!name.has_value() && "PoshRuntime::initRuntime must not be used with a PoshRuntimeMock!"); - IOX_EXPECTS(runtime.has_value() && "This should never happen! If you see this, something went horribly wrong!"); + IOX_EXPECTS_WITH_MSG(!name.has_value(), "PoshRuntime::initRuntime must not be used with a PoshRuntimeMock!"); + IOX_EXPECTS_WITH_MSG(runtime.has_value(), + "This should never happen! If you see this, something went horribly wrong!"); return *runtime.value(); } From bd1bdcb1c434ea19ed8e5831c76000b5319ea3de Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 9 Nov 2023 17:46:06 +0100 Subject: [PATCH 08/12] iox-#1391 Re-add posix namespace --- .../release-notes/iceoryx-unreleased.md | 6 +-- .../include/iox/{ => posix}/message_queue.hpp | 43 ++++++++++--------- .../include/iox/{ => posix}/named_pipe.hpp | 39 +++++++++-------- .../posix/ipc/source/message_queue.cpp | 36 ++++++++-------- iceoryx_dust/posix/ipc/source/named_pipe.cpp | 16 ++----- .../iox/{ => posix}/signal_watcher.hpp | 20 +++++---- .../posix/sync/source/signal_watcher.cpp | 12 +++--- .../test_posix_sync_signal_watcher.cpp | 3 +- ...ice_callbacks_listener_as_class_member.cpp | 4 +- .../callbacks/ice_callbacks_publisher.cpp | 4 +- .../callbacks/ice_callbacks_subscriber.cpp | 6 +-- .../complexdata/iox_publisher_complexdata.cpp | 4 +- .../complexdata/iox_publisher_vector.cpp | 4 +- .../iox_subscriber_complexdata.cpp | 4 +- .../complexdata/iox_subscriber_vector.cpp | 4 +- .../ice_access_control/iox_display_app.cpp | 4 +- .../ice_access_control/iox_radar_app.cpp | 4 +- .../icedelivery/iox_publisher.cpp | 4 +- .../icedelivery/iox_publisher_untyped.cpp | 4 +- .../icedelivery/iox_subscriber.cpp | 4 +- .../icedelivery/iox_subscriber_untyped.cpp | 4 +- .../icediscovery/iox_discovery_monitor.cpp | 4 +- .../icediscovery/iox_find_service.cpp | 4 +- .../icediscovery/iox_offer_service.cpp | 4 +- .../icediscovery/iox_wait_for_service.cpp | 2 +- .../icehello/iox_publisher_helloworld.cpp | 4 +- .../icehello/iox_subscriber_helloworld.cpp | 4 +- .../iceoptions/iox_publisher_with_options.cpp | 6 +-- .../iox_subscriber_with_options.cpp | 4 +- .../request_response/client_cxx_basic.cpp | 4 +- .../request_response/client_cxx_untyped.cpp | 4 +- .../request_response/client_cxx_waitset.cpp | 2 +- .../request_response/server_cxx_basic.cpp | 4 +- .../request_response/server_cxx_listener.cpp | 4 +- .../request_response/server_cxx_untyped.cpp | 4 +- .../singleprocess/single_process.cpp | 8 ++-- .../user_header/publisher_cxx_api.cpp | 4 +- .../user_header/publisher_untyped_cxx_api.cpp | 4 +- .../user_header/subscriber_cxx_api.cpp | 4 +- .../subscriber_untyped_cxx_api.cpp | 4 +- .../waitset/ice_waitset_publisher.cpp | 4 +- iceoryx_hoofs/cmake/IceoryxPlatform.cmake | 2 +- .../internal/runtime/ipc_interface_base.hpp | 8 ++-- .../include/iceoryx_posh/roudi/roudi_app.hpp | 2 +- .../roudi/application/iceoryx_roudi_app.cpp | 4 +- .../source/roudi/application/roudi_app.cpp | 4 +- .../source/runtime/ipc_interface_base.cpp | 6 +-- .../test_mq_interface_startup_race.cpp | 2 +- .../test_runtime_ipc_interface.cpp | 4 +- 49 files changed, 171 insertions(+), 172 deletions(-) rename iceoryx_dust/posix/ipc/include/iox/{ => posix}/message_queue.hpp (74%) rename iceoryx_dust/posix/ipc/include/iox/{ => posix}/named_pipe.hpp (82%) rename iceoryx_dust/posix/sync/include/iox/{ => posix}/signal_watcher.hpp (86%) diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 147a14741a..fec31c8b56 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -998,7 +998,7 @@ #include "iceoryx_hoofs/posix_wrapper/internal/message_queue.hpp" // after - #include "iox/message_queue.hpp" + #include "iox/posix/message_queue.hpp" ``` ```cpp @@ -1006,7 +1006,7 @@ #include "iceoryx_hoofs/posix_wrapper/named_pipe.hpp" // after - #include "iox/named_pipe.hpp" + #include "iox/posix/named_pipe.hpp" ``` ```cpp @@ -1014,7 +1014,7 @@ #include "iceoryx_hoofs/posix_wrapper/signal_watcher.hpp" // after - #include "iceoryx_dust/posix_wrapper/signal_watcher.hpp" + #include "iox/posix/signal_watcher.hpp" ``` ```cpp diff --git a/iceoryx_dust/posix/ipc/include/iox/message_queue.hpp b/iceoryx_dust/posix/ipc/include/iox/posix/message_queue.hpp similarity index 74% rename from iceoryx_dust/posix/ipc/include/iox/message_queue.hpp rename to iceoryx_dust/posix/ipc/include/iox/posix/message_queue.hpp index 2c2f7a965e..1a48f93d65 100644 --- a/iceoryx_dust/posix/ipc/include/iox/message_queue.hpp +++ b/iceoryx_dust/posix/ipc/include/iox/posix/message_queue.hpp @@ -30,12 +30,14 @@ namespace iox { +namespace posix +{ class MessageQueueBuilder; /// @brief Wrapper class for posix message queue /// /// @code -/// auto mq = iox::MessageQueueBuilder() +/// auto mq = iox::posix::MessageQueueBuilder() /// .name("/MqName123") /// .channelSide(iox::posix::IpcChannelSide::CLIENT) /// .create(); @@ -67,28 +69,27 @@ class MessageQueue ~MessageQueue() noexcept; - static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; + static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; /// @brief send a message to queue using std::string. /// @return true if sent without errors, false otherwise - expected send(const std::string& msg) const noexcept; + expected send(const std::string& msg) const noexcept; /// @todo iox-#1693 zero copy receive with receive(iox::string&); iox::string would be the buffer for mq_receive /// @brief receive message from queue using std::string. /// @return number of characters received. In case of an error, returns -1 and msg is empty. - expected receive() const noexcept; + expected receive() const noexcept; /// @brief try to receive message from queue for a given timeout duration using std::string. Only defined /// for NON_BLOCKING == false. /// @return optional containing the received string. In case of an error, nullopt type is returned. - expected timedReceive(const units::Duration& timeout) const noexcept; + expected timedReceive(const units::Duration& timeout) const noexcept; /// @brief try to send a message to the queue for a given timeout duration using std::string - expected timedSend(const std::string& msg, - const units::Duration& timeout) const noexcept; + expected timedSend(const std::string& msg, const units::Duration& timeout) const noexcept; - static expected isOutdated() noexcept; + static expected isOutdated() noexcept; private: friend class MessageQueueBuilder; @@ -96,24 +97,23 @@ class MessageQueue MessageQueue(const IpcChannelName_t& name, const mq_attr attributes, mqd_t mqDescriptor, - const posix::IpcChannelSide channelSide) noexcept; + const IpcChannelSide channelSide) noexcept; - static expected - open(const IpcChannelName_t& name, mq_attr& attributes, const posix::IpcChannelSide channelSide) noexcept; + static expected + open(const IpcChannelName_t& name, mq_attr& attributes, const IpcChannelSide channelSide) noexcept; - expected close() noexcept; - expected unlink() noexcept; - posix::IpcChannelError errnoToEnum(const int32_t errnum) const noexcept; - static posix::IpcChannelError errnoToEnum(const IpcChannelName_t& name, const int32_t errnum) noexcept; - static expected - sanitizeIpcChannelName(const IpcChannelName_t& name) noexcept; - expected destroy() noexcept; + expected close() noexcept; + expected unlink() noexcept; + IpcChannelError errnoToEnum(const int32_t errnum) const noexcept; + static IpcChannelError errnoToEnum(const IpcChannelName_t& name, const int32_t errnum) noexcept; + static expected sanitizeIpcChannelName(const IpcChannelName_t& name) noexcept; + expected destroy() noexcept; private: IpcChannelName_t m_name; mq_attr m_attributes{}; mqd_t m_mqDescriptor = INVALID_DESCRIPTOR; - posix::IpcChannelSide m_channelSide = posix::IpcChannelSide::CLIENT; + IpcChannelSide m_channelSide = IpcChannelSide::CLIENT; #ifdef __QNX__ static constexpr int TIMEOUT_ERRNO = EINTR; @@ -133,7 +133,7 @@ class MessageQueueBuilder IOX_BUILDER_PARAMETER(IpcChannelName_t, name, "") /// @brief Defines how the message queue is opened, i.e. as client or server - IOX_BUILDER_PARAMETER(posix::IpcChannelSide, channelSide, posix::IpcChannelSide::CLIENT) + IOX_BUILDER_PARAMETER(IpcChannelSide, channelSide, IpcChannelSide::CLIENT) /// @brief Defines the max message size of the message queue IOX_BUILDER_PARAMETER(uint64_t, maxMsgSize, MessageQueue::MAX_MESSAGE_SIZE) @@ -144,9 +144,10 @@ class MessageQueueBuilder public: /// @brief create a message queue /// @return On success a 'MessageQueue' is returned and on failure an 'IpcChannelError'. - expected create() const noexcept; + expected create() const noexcept; }; +} // namespace posix } // namespace iox #endif // IOX_DUST_POSIX_IPC_MESSAGE_QUEUE_HPP diff --git a/iceoryx_dust/posix/ipc/include/iox/named_pipe.hpp b/iceoryx_dust/posix/ipc/include/iox/posix/named_pipe.hpp similarity index 82% rename from iceoryx_dust/posix/ipc/include/iox/named_pipe.hpp rename to iceoryx_dust/posix/ipc/include/iox/posix/named_pipe.hpp index c227a7360e..f259ce4f64 100644 --- a/iceoryx_dust/posix/ipc/include/iox/named_pipe.hpp +++ b/iceoryx_dust/posix/ipc/include/iox/posix/named_pipe.hpp @@ -35,6 +35,8 @@ namespace iox { +namespace posix +{ class NamedPipeBuilder; class NamedPipe @@ -70,51 +72,51 @@ class NamedPipe /// @brief removes a named pipe artifact from the system /// @return true if the artifact was removed, false when no artifact was found and /// IpcChannelError::INTERNAL_LOGIC_ERROR when shm_unlink failed - static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; + static expected unlinkIfExists(const IpcChannelName_t& name) noexcept; /// @brief tries to send a message via the named pipe. if the pipe is full IpcChannelError::TIMEOUT is returned /// @return on failure an error which describes the failure - expected trySend(const std::string& message) const noexcept; + expected trySend(const std::string& message) const noexcept; /// @brief sends a message via the named pipe. if the pipe is full this call is blocking until the message could be /// delivered /// @param[in] message the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE /// @return success when message was sent otherwise an error which describes the failure - expected send(const std::string& message) const noexcept; + expected send(const std::string& message) const noexcept; /// @brief sends a message via the named pipe. /// @param[in] message the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE /// @param[in] timeout the timeout on how long this method should retry to send the message /// @return success when message was sent otherwise an error which describes the failure - expected timedSend(const std::string& message, - const units::Duration& timeout) const noexcept; + expected timedSend(const std::string& message, + const units::Duration& timeout) const noexcept; /// @brief tries to receive a message via the named pipe. if the pipe is empty IpcChannelError::TIMEOUT is returned /// @return on success a string containing the message, otherwise an error which describes the failure - expected tryReceive() const noexcept; + expected tryReceive() const noexcept; /// @brief receives a message via the named pipe. if the pipe is empty this call is blocking until a message was /// received /// @return on success a string containing the message, otherwise an error which describes the failure - expected receive() const noexcept; + expected receive() const noexcept; /// @brief receives a message via the named pipe. /// @param[in] timeout the timeout on how long this method should retry to receive a message /// @return on success a string containing the message, otherwise an error which describes the failure - expected timedReceive(const units::Duration& timeout) const noexcept; + expected timedReceive(const units::Duration& timeout) const noexcept; private: friend class NamedPipeBuilder; class NamedPipeData; - NamedPipe(posix::SharedMemoryObject&& sharedMemory, NamedPipeData* data) noexcept; + NamedPipe(SharedMemoryObject&& sharedMemory, NamedPipeData* data) noexcept; template static IpcChannelName_t mapToSharedMemoryName(const Prefix& p, const IpcChannelName_t& name) noexcept; /// @brief destroys an initialized named pipe. /// @return is always successful - expected destroy() noexcept; + expected destroy() noexcept; class NamedPipeData { @@ -127,10 +129,10 @@ class NamedPipe NamedPipeData& operator=(NamedPipeData&& rhs) = delete; ~NamedPipeData() = default; - posix::UnnamedSemaphore& sendSemaphore() noexcept; - posix::UnnamedSemaphore& receiveSemaphore() noexcept; + UnnamedSemaphore& sendSemaphore() noexcept; + UnnamedSemaphore& receiveSemaphore() noexcept; - expected initialize(const uint32_t maxMsgNumber) noexcept; + expected initialize(const uint32_t maxMsgNumber) noexcept; bool waitForInitialization() const noexcept; bool hasValidState() const noexcept; @@ -144,12 +146,12 @@ class NamedPipe static constexpr units::Duration WAIT_FOR_INIT_SLEEP_TIME = units::Duration::fromMilliseconds(1); std::atomic initializationGuard{INVALID_DATA}; - optional m_sendSemaphore; - optional m_receiveSemaphore; + optional m_sendSemaphore; + optional m_receiveSemaphore; }; private: - posix::SharedMemoryObject m_sharedMemory; + SharedMemoryObject m_sharedMemory; NamedPipeData* m_data = nullptr; }; @@ -159,7 +161,7 @@ class NamedPipeBuilder IOX_BUILDER_PARAMETER(IpcChannelName_t, name, "") /// @brief Defines how the named pipe is opened, i.e. as client or server - IOX_BUILDER_PARAMETER(posix::IpcChannelSide, channelSide, posix::IpcChannelSide::CLIENT) + IOX_BUILDER_PARAMETER(IpcChannelSide, channelSide, IpcChannelSide::CLIENT) /// @brief Defines the max message size of the named pipe IOX_BUILDER_PARAMETER(size_t, maxMsgSize, NamedPipe::MAX_MESSAGE_SIZE) @@ -170,9 +172,10 @@ class NamedPipeBuilder public: /// @brief create a named pipe /// @return On success a 'NamedPipe' is returned and on failure an 'IpcChannelError'. - expected create() const noexcept; + expected create() const noexcept; }; +} // namespace posix } // namespace iox #endif // IOX_DUST_POSIX_IPC_NAMED_PIPE_HPP diff --git a/iceoryx_dust/posix/ipc/source/message_queue.cpp b/iceoryx_dust/posix/ipc/source/message_queue.cpp index 00a4f1d607..e9336e8c85 100644 --- a/iceoryx_dust/posix/ipc/source/message_queue.cpp +++ b/iceoryx_dust/posix/ipc/source/message_queue.cpp @@ -16,7 +16,7 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iox/message_queue.hpp" +#include "iox/posix/message_queue.hpp" #include "iceoryx_hoofs/posix_wrapper/posix_call.hpp" #include "iceoryx_platform/fcntl.hpp" #include "iceoryx_platform/platform_correction.hpp" @@ -28,9 +28,8 @@ namespace iox { -using posix::IpcChannelError; -using posix::IpcChannelSide; - +namespace posix +{ expected MessageQueueBuilder::create() const noexcept { auto sanitzedNameResult = MessageQueue::sanitizeIpcChannelName(m_name); @@ -48,7 +47,7 @@ expected MessageQueueBuilder::create() const noex if (m_channelSide == IpcChannelSide::SERVER) { - posix::posixCall(mq_unlink)(sanitizedName.c_str()) + posixCall(mq_unlink)(sanitizedName.c_str()) .failureReturnValue(MessageQueue::ERROR_CODE) .ignoreErrnos(ENOENT) .evaluate() @@ -135,7 +134,7 @@ expected MessageQueue::unlinkIfExists(const IpcChannelNam } - auto mqCall = posix::posixCall(mq_unlink)(sanitizedIpcChannelName->c_str()) + auto mqCall = posixCall(mq_unlink)(sanitizedIpcChannelName->c_str()) .failureReturnValue(ERROR_CODE) .ignoreErrnos(ENOENT) .evaluate(); @@ -177,9 +176,8 @@ expected MessageQueue::send(const std::string& msg) const return err(IpcChannelError::MESSAGE_TOO_LONG); } - auto mqCall = posix::posixCall(mq_send)(m_mqDescriptor, msg.c_str(), messageSize, 1U) - .failureReturnValue(ERROR_CODE) - .evaluate(); + auto mqCall = + posixCall(mq_send)(m_mqDescriptor, msg.c_str(), messageSize, 1U).failureReturnValue(ERROR_CODE).evaluate(); if (mqCall.has_error()) { @@ -195,7 +193,7 @@ expected MessageQueue::receive() const noexcept /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) char message[MAX_MESSAGE_SIZE]; - auto mqCall = posix::posixCall(mq_receive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr) + auto mqCall = posixCall(mq_receive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr) .failureReturnValue(ERROR_CODE) .evaluate(); @@ -229,11 +227,10 @@ MessageQueue::open(const IpcChannelName_t& name, mq_attr& attributes, const IpcC // the mask will be applied to the permissions, therefore we need to set it to 0 mode_t umaskSaved = umask(0); - auto mqCall = - posix::posixCall(iox_mq_open4)(sanitizedName.c_str(), openFlags, MessageQueue::FILE_MODE, &attributes) - .failureReturnValue(MessageQueue::INVALID_DESCRIPTOR) - .suppressErrorMessagesForErrnos(ENOENT) - .evaluate(); + auto mqCall = posixCall(iox_mq_open4)(sanitizedName.c_str(), openFlags, MessageQueue::FILE_MODE, &attributes) + .failureReturnValue(MessageQueue::INVALID_DESCRIPTOR) + .suppressErrorMessagesForErrnos(ENOENT) + .evaluate(); umask(umaskSaved); @@ -248,7 +245,7 @@ MessageQueue::open(const IpcChannelName_t& name, mq_attr& attributes, const IpcC expected MessageQueue::close() noexcept { - auto mqCall = posix::posixCall(mq_close)(m_mqDescriptor).failureReturnValue(ERROR_CODE).evaluate(); + auto mqCall = posixCall(mq_close)(m_mqDescriptor).failureReturnValue(ERROR_CODE).evaluate(); if (mqCall.has_error()) { @@ -265,7 +262,7 @@ expected MessageQueue::unlink() noexcept return ok(); } - auto mqCall = posix::posixCall(mq_unlink)(m_name.c_str()).failureReturnValue(ERROR_CODE).evaluate(); + auto mqCall = posixCall(mq_unlink)(m_name.c_str()).failureReturnValue(ERROR_CODE).evaluate(); if (mqCall.has_error()) { return err(errnoToEnum(mqCall.error().errnum)); @@ -281,7 +278,7 @@ expected MessageQueue::timedReceive(const units::D /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) char message[MAX_MESSAGE_SIZE]; - auto mqCall = posix::posixCall(mq_timedreceive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr, &timeOut) + auto mqCall = posixCall(mq_timedreceive)(m_mqDescriptor, &message[0], MAX_MESSAGE_SIZE, nullptr, &timeOut) .failureReturnValue(ERROR_CODE) // don't use the suppressErrorMessagesForErrnos method since QNX used EINTR instead of ETIMEDOUT .ignoreErrnos(TIMEOUT_ERRNO) @@ -313,7 +310,7 @@ expected MessageQueue::timedSend(const std::string& msg, timespec timeOut = timeout.timespec(units::TimeSpecReference::Epoch); - auto mqCall = posix::posixCall(mq_timedsend)(m_mqDescriptor, msg.c_str(), messageSize, 1U, &timeOut) + auto mqCall = posixCall(mq_timedsend)(m_mqDescriptor, msg.c_str(), messageSize, 1U, &timeOut) .failureReturnValue(ERROR_CODE) // don't use the suppressErrorMessagesForErrnos method since QNX used EINTR instead of ETIMEDOUT .ignoreErrnos(TIMEOUT_ERRNO) @@ -409,4 +406,5 @@ expected MessageQueue::sanitizeIpcChannelName return ok(name); } +} // namespace posix } // namespace iox diff --git a/iceoryx_dust/posix/ipc/source/named_pipe.cpp b/iceoryx_dust/posix/ipc/source/named_pipe.cpp index 87fc817c91..b112cbcc1b 100644 --- a/iceoryx_dust/posix/ipc/source/named_pipe.cpp +++ b/iceoryx_dust/posix/ipc/source/named_pipe.cpp @@ -15,7 +15,7 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iox/named_pipe.hpp" +#include "iox/posix/named_pipe.hpp" #include "iox/bump_allocator.hpp" #include "iox/deadline_timer.hpp" #include "iox/filesystem.hpp" @@ -27,17 +27,8 @@ namespace iox { -using posix::AccessMode; -using posix::IpcChannelError; -using posix::IpcChannelSide; -using posix::OpenMode; -using posix::SemaphoreWaitState; -using posix::SharedMemory; -using posix::SharedMemoryObject; -using posix::SharedMemoryObjectBuilder; -using posix::UnnamedSemaphore; -using posix::UnnamedSemaphoreBuilder; - +namespace posix +{ /// NOLINTJUSTIFICATION see declaration in header /// NOLINTNEXTLINE(hicpp-avoid-c-arrays,cppcoreguidelines-avoid-c-arrays) constexpr const char NamedPipe::NAMED_PIPE_PREFIX[]; @@ -370,4 +361,5 @@ bool NamedPipe::NamedPipeData::hasValidState() const noexcept return initializationGuard.load() == VALID_DATA; } +} // namespace posix } // namespace iox diff --git a/iceoryx_dust/posix/sync/include/iox/signal_watcher.hpp b/iceoryx_dust/posix/sync/include/iox/posix/signal_watcher.hpp similarity index 86% rename from iceoryx_dust/posix/sync/include/iox/signal_watcher.hpp rename to iceoryx_dust/posix/sync/include/iox/posix/signal_watcher.hpp index 2923f94d5c..1108f9f3ca 100644 --- a/iceoryx_dust/posix/sync/include/iox/signal_watcher.hpp +++ b/iceoryx_dust/posix/sync/include/iox/posix/signal_watcher.hpp @@ -13,8 +13,9 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_DUST_POSIX_WRAPPER_SIGNAL_WATCHER_HPP -#define IOX_DUST_POSIX_WRAPPER_SIGNAL_WATCHER_HPP + +#ifndef IOX_DUST_POSIX_SYNC_SIGNAL_WATCHER_HPP +#define IOX_DUST_POSIX_SYNC_SIGNAL_WATCHER_HPP #include "iceoryx_hoofs/posix_wrapper/signal_handler.hpp" #include "iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp" @@ -24,6 +25,8 @@ namespace iox { +namespace posix +{ /// @brief The SignalWatcher waits for SIGINT and SIGTERM. One can wait until the /// signal has occurred or ask the watcher if it has occurred. /// @code @@ -31,7 +34,7 @@ namespace iox /// #include /// void loopUntilTerminationRequested() /// { -/// while(!iox::hasTerminationRequested()) +/// while(!iox::posix::hasTerminationRequested()) /// { /// // your algorithm /// } @@ -40,7 +43,7 @@ namespace iox /// // another possibility is to block until SIGINT or SIGTERM has occurred /// void blockUntilCtrlC() { /// // your objects which spawn threads -/// iox::waitForTerminationRequest(); +/// iox::posix::waitForTerminationRequest(); /// } /// @endcode class SignalWatcher @@ -68,11 +71,11 @@ class SignalWatcher private: friend void internalSignalHandler(int) noexcept; mutable std::atomic m_numberOfWaiters{0U}; - mutable optional m_semaphore; + mutable optional m_semaphore; std::atomic_bool m_hasSignalOccurred{false}; - posix::SignalGuard m_sigTermGuard; - posix::SignalGuard m_sigIntGuard; + SignalGuard m_sigTermGuard; + SignalGuard m_sigIntGuard; }; /// @brief convenience function, calls SignalWatcher::getInstance().waitForSignal(); @@ -80,6 +83,7 @@ void waitForTerminationRequest() noexcept; /// @brief convenience function, calls SignalWatcher::getInstance().wasSignalTriggered(); bool hasTerminationRequested() noexcept; +} // namespace posix } // namespace iox -#endif +#endif // IOX_DUST_POSIX_SYNC_SIGNAL_WATCHER_HPP diff --git a/iceoryx_dust/posix/sync/source/signal_watcher.cpp b/iceoryx_dust/posix/sync/source/signal_watcher.cpp index 73a3d71251..c83472a521 100644 --- a/iceoryx_dust/posix/sync/source/signal_watcher.cpp +++ b/iceoryx_dust/posix/sync/source/signal_watcher.cpp @@ -14,11 +14,13 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "iceoryx_platform/unistd.hpp" namespace iox { +namespace posix +{ void internalSignalHandler(int) noexcept { auto& instance = SignalWatcher::getInstance(); @@ -43,11 +45,10 @@ void internalSignalHandler(int) noexcept SignalWatcher::SignalWatcher() noexcept : m_sigTermGuard( - registerSignalHandler(posix::Signal::TERM, internalSignalHandler).expect("Unable to register Signal::TERM")) - , m_sigIntGuard( - registerSignalHandler(posix::Signal::INT, internalSignalHandler).expect("Unable to register Signal::INT")) + registerSignalHandler(Signal::TERM, internalSignalHandler).expect("Unable to register Signal::TERM")) + , m_sigIntGuard(registerSignalHandler(Signal::INT, internalSignalHandler).expect("Unable to register Signal::INT")) { - posix::UnnamedSemaphoreBuilder() + UnnamedSemaphoreBuilder() .isInterProcessCapable(false) .create(m_semaphore) @@ -88,4 +89,5 @@ bool hasTerminationRequested() noexcept { return SignalWatcher::getInstance().wasSignalTriggered(); } +} // namespace posix } // namespace iox diff --git a/iceoryx_dust/test/moduletests/test_posix_sync_signal_watcher.cpp b/iceoryx_dust/test/moduletests/test_posix_sync_signal_watcher.cpp index bd543864f3..f4c820a67e 100644 --- a/iceoryx_dust/test/moduletests/test_posix_sync_signal_watcher.cpp +++ b/iceoryx_dust/test/moduletests/test_posix_sync_signal_watcher.cpp @@ -16,14 +16,13 @@ #include "iceoryx_hoofs/testing/barrier.hpp" #include "iceoryx_hoofs/testing/watch_dog.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "test.hpp" #include namespace { using namespace ::testing; -using namespace iox; using namespace iox::posix; class SignalWatcherTester : public SignalWatcher diff --git a/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp b/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp index b5209fb006..0ca9b26cb6 100644 --- a/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp +++ b/iceoryx_examples/callbacks/ice_callbacks_listener_as_class_member.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/user_trigger.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iox/optional.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -112,7 +112,7 @@ int main() CounterService counterService; - iox::waitForTerminationRequest(); + iox::posix::waitForTerminationRequest(); //! [init] return (EXIT_SUCCESS); diff --git a/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp b/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp index 29ba9d8085..8ebc494f07 100644 --- a/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp +++ b/iceoryx_examples/callbacks/ice_callbacks_publisher.cpp @@ -16,7 +16,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -32,7 +32,7 @@ void sending() iox::popo::Publisher myPublisherLeft({"Radar", "FrontLeft", "Counter"}); iox::popo::Publisher myPublisherRight({"Radar", "FrontRight", "Counter"}); - for (uint32_t counter = 0U; !iox::hasTerminationRequested(); ++counter) + for (uint32_t counter = 0U; !iox::posix::hasTerminationRequested(); ++counter) { if (counter % 3 == 0) { diff --git a/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp b/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp index e25cc58569..c80e713b09 100644 --- a/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp +++ b/iceoryx_examples/callbacks/ice_callbacks_subscriber.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/user_trigger.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iox/optional.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -91,7 +91,7 @@ int main() // send a heartbeat every 4 seconds //! [create heartbeat] std::thread heartbeatThread([&] { - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { heartbeat.trigger(); std::this_thread::sleep_for(std::chrono::seconds(4)); @@ -131,7 +131,7 @@ int main() // wait until someone presses CTRL+C //! [wait for sigterm] - iox::waitForTerminationRequest(); + iox::posix::waitForTerminationRequest(); //! [wait for sigterm] // optional detachEvent, but not required. diff --git a/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp b/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp index 8d515a4e41..9ccf54ee4b 100644 --- a/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp +++ b/iceoryx_examples/complexdata/iox_publisher_complexdata.cpp @@ -18,7 +18,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" constexpr char APP_NAME[] = "iox-cpp-publisher-complexdata"; @@ -46,7 +46,7 @@ int main() uint64_t ct = 0; // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { ++ct; publisher.loan() diff --git a/iceoryx_examples/complexdata/iox_publisher_vector.cpp b/iceoryx_examples/complexdata/iox_publisher_vector.cpp index f1834ac29a..2e271d2e1e 100644 --- a/iceoryx_examples/complexdata/iox_publisher_vector.cpp +++ b/iceoryx_examples/complexdata/iox_publisher_vector.cpp @@ -18,7 +18,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" constexpr char APP_NAME[] = "iox-cpp-publisher-vector"; @@ -34,7 +34,7 @@ int main() uint64_t ct = 0; // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { publisher.loan() .and_then([&](auto& sample) { diff --git a/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp b/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp index 35f75181af..0ca1156fc2 100644 --- a/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp +++ b/iceoryx_examples/complexdata/iox_subscriber_complexdata.cpp @@ -18,7 +18,7 @@ #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "iox/string.hpp" constexpr char APP_NAME[] = "iox-cpp-subscriber-complexdata"; @@ -32,7 +32,7 @@ int main() iox::popo::Subscriber subscriber({"Group", "Instance", "ComplexDataTopic"}); // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { subscriber.take() .and_then([](auto& sample) { diff --git a/iceoryx_examples/complexdata/iox_subscriber_vector.cpp b/iceoryx_examples/complexdata/iox_subscriber_vector.cpp index 90a8779c6b..ba2bb825e9 100644 --- a/iceoryx_examples/complexdata/iox_subscriber_vector.cpp +++ b/iceoryx_examples/complexdata/iox_subscriber_vector.cpp @@ -16,7 +16,7 @@ #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "iox/string.hpp" #include "iox/vector.hpp" @@ -31,7 +31,7 @@ int main() iox::popo::Subscriber> subscriber({"Radar", "FrontRight", "VectorData"}); // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { subscriber.take() .and_then([](auto& sample) { diff --git a/iceoryx_examples/ice_access_control/iox_display_app.cpp b/iceoryx_examples/ice_access_control/iox_display_app.cpp index 0ce9133e2b..bba273145f 100644 --- a/iceoryx_examples/ice_access_control/iox_display_app.cpp +++ b/iceoryx_examples/ice_access_control/iox_display_app.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include @@ -35,7 +35,7 @@ int main() iox::popo::Publisher publisher({"Radar", "HMI-Display", "Object"}); // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { auto takeResult = subscriber.take(); diff --git a/iceoryx_examples/ice_access_control/iox_radar_app.cpp b/iceoryx_examples/ice_access_control/iox_radar_app.cpp index 36c61ebaac..8222c840b0 100644 --- a/iceoryx_examples/ice_access_control/iox_radar_app.cpp +++ b/iceoryx_examples/ice_access_control/iox_radar_app.cpp @@ -18,7 +18,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include @@ -32,7 +32,7 @@ int main() iox::popo::Publisher publisher({"Radar", "FrontLeft", "Object"}); double ct = 0.0; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { ++ct; diff --git a/iceoryx_examples/icedelivery/iox_publisher.cpp b/iceoryx_examples/icedelivery/iox_publisher.cpp index 0b1ae0d7c4..6f50237688 100644 --- a/iceoryx_examples/icedelivery/iox_publisher.cpp +++ b/iceoryx_examples/icedelivery/iox_publisher.cpp @@ -21,7 +21,7 @@ #include "iceoryx_posh/popo/publisher.hpp" //! [include publisher] #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include @@ -41,7 +41,7 @@ int main() //! [create publisher] double ct = 0.0; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { ++ct; double sampleValue1 = ct + 89; diff --git a/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp b/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp index 57ad1a46df..f5ce53fdf2 100644 --- a/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp +++ b/iceoryx_examples/icedelivery/iox_publisher_untyped.cpp @@ -22,7 +22,7 @@ //! [includes] #include "iceoryx_posh/popo/untyped_publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [includes] #include @@ -39,7 +39,7 @@ int main() //! [create untyped publisher] double ct = 0.0; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { ++ct; diff --git a/iceoryx_examples/icedelivery/iox_subscriber.cpp b/iceoryx_examples/icedelivery/iox_subscriber.cpp index 267b61bcb3..4477fd0b37 100644 --- a/iceoryx_examples/icedelivery/iox_subscriber.cpp +++ b/iceoryx_examples/icedelivery/iox_subscriber.cpp @@ -21,7 +21,7 @@ #include "iceoryx_posh/popo/subscriber.hpp" //! [include subscriber] #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include @@ -37,7 +37,7 @@ int main() //! [create subscriber] // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { subscriber .take() diff --git a/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp b/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp index a940c738aa..10b82b9f6f 100644 --- a/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp +++ b/iceoryx_examples/icedelivery/iox_subscriber_untyped.cpp @@ -20,7 +20,7 @@ #include "iceoryx_posh/popo/untyped_subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [includes] #include @@ -38,7 +38,7 @@ int main() // run until interrupted by Ctrl-C //! [loop] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { subscriber .take() diff --git a/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp b/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp index c182523884..daf68248d6 100644 --- a/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp +++ b/iceoryx_examples/icediscovery/iox_discovery_monitor.cpp @@ -19,7 +19,7 @@ //! [include custom discovery] #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include @@ -76,7 +76,7 @@ int main() discovery.registerCallback(callback); //! [register callback] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { // here the app would run its functional code while the // service availability is monitored in the background diff --git a/iceoryx_examples/icediscovery/iox_find_service.cpp b/iceoryx_examples/icediscovery/iox_find_service.cpp index 7f3a42e463..0b3769d05d 100644 --- a/iceoryx_examples/icediscovery/iox_find_service.cpp +++ b/iceoryx_examples/icediscovery/iox_find_service.cpp @@ -15,7 +15,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [include ServiceDiscovery] #include "iceoryx_posh/runtime/service_discovery.hpp" //! [include ServiceDiscovery] @@ -39,7 +39,7 @@ int main() iox::runtime::ServiceDiscovery serviceDiscovery; //! [create ServiceDiscovery object] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { std::cout << "\n=========================================" << std::endl; diff --git a/iceoryx_examples/icediscovery/iox_offer_service.cpp b/iceoryx_examples/icediscovery/iox_offer_service.cpp index c05b5a9ac2..3643011a6a 100644 --- a/iceoryx_examples/icediscovery/iox_offer_service.cpp +++ b/iceoryx_examples/icediscovery/iox_offer_service.cpp @@ -16,7 +16,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" constexpr char APP_NAME[] = "iox-offer-service"; @@ -37,7 +37,7 @@ int main() cameraPublishers.emplace_back(iox::capro::ServiceDescription{"Camera", "BackLeft", "Image"}); bool offer = false; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { if (offer) { diff --git a/iceoryx_examples/icediscovery/iox_wait_for_service.cpp b/iceoryx_examples/icediscovery/iox_wait_for_service.cpp index cbdf8e80e8..12f5928923 100644 --- a/iceoryx_examples/icediscovery/iox_wait_for_service.cpp +++ b/iceoryx_examples/icediscovery/iox_wait_for_service.cpp @@ -19,7 +19,7 @@ //! [include custom discovery] #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include diff --git a/iceoryx_examples/icehello/iox_publisher_helloworld.cpp b/iceoryx_examples/icehello/iox_publisher_helloworld.cpp index 5394fba6ee..134057c1af 100644 --- a/iceoryx_examples/icehello/iox_publisher_helloworld.cpp +++ b/iceoryx_examples/icehello/iox_publisher_helloworld.cpp @@ -19,7 +19,7 @@ //! [include topic] //! [include sig watcher] -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [include sig watcher] //! [include] @@ -43,7 +43,7 @@ int main() double ct = 0.0; //! [wait for term] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) //! [wait for term] { ++ct; diff --git a/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp b/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp index af2f4ba1e1..1e850d58d0 100644 --- a/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp +++ b/iceoryx_examples/icehello/iox_subscriber_helloworld.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [include] #include @@ -36,7 +36,7 @@ int main() //! [initialize subscriber] // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { //! [receive] auto takeResult = subscriber.take(); diff --git a/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp b/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp index 8b898a3416..0e4da4d37e 100644 --- a/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp +++ b/iceoryx_examples/iceoptions/iox_publisher_with_options.cpp @@ -18,7 +18,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include @@ -63,7 +63,7 @@ int main() double ct = 0.0; std::thread publishData([&]() { - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { ++ct; @@ -76,7 +76,7 @@ int main() } }); - iox::waitForTerminationRequest(); + iox::posix::waitForTerminationRequest(); // this is optional, but since the iox::popo::ConsumerTooSlowPolicy::WAIT_FOR_CONSUMER option is used, // a slow subscriber might block the shutdown and this call unblocks the publisher diff --git a/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp b/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp index 566e396514..b5d7204054 100644 --- a/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp +++ b/iceoryx_examples/iceoptions/iox_subscriber_with_options.cpp @@ -18,7 +18,7 @@ #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include @@ -76,7 +76,7 @@ int main() //! [subscribe] // run until interrupted by Ctrl-C - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { subscriber.take().and_then( [](auto& sample) { std::cout << APP_NAME << " got value: " << sample->x << std::endl; }); diff --git a/iceoryx_examples/request_response/client_cxx_basic.cpp b/iceoryx_examples/request_response/client_cxx_basic.cpp index 7e5fd88ec7..66dea43202 100644 --- a/iceoryx_examples/request_response/client_cxx_basic.cpp +++ b/iceoryx_examples/request_response/client_cxx_basic.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/client.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -40,7 +40,7 @@ int main() uint64_t fibonacciCurrent = 1; int64_t requestSequenceId = 0; int64_t expectedResponseSequenceId = requestSequenceId; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { //! [send request] client.loan() diff --git a/iceoryx_examples/request_response/client_cxx_untyped.cpp b/iceoryx_examples/request_response/client_cxx_untyped.cpp index 96793ae311..70d657ea1d 100644 --- a/iceoryx_examples/request_response/client_cxx_untyped.cpp +++ b/iceoryx_examples/request_response/client_cxx_untyped.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/untyped_client.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -40,7 +40,7 @@ int main() uint64_t fibonacciCurrent = 1; int64_t requestSequenceId = 0; int64_t expectedResponseSequenceId = requestSequenceId; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { //! [send request] client.loan(sizeof(AddRequest), alignof(AddRequest)) diff --git a/iceoryx_examples/request_response/client_cxx_waitset.cpp b/iceoryx_examples/request_response/client_cxx_waitset.cpp index 8088b4901f..040485f7eb 100644 --- a/iceoryx_examples/request_response/client_cxx_waitset.cpp +++ b/iceoryx_examples/request_response/client_cxx_waitset.cpp @@ -21,7 +21,7 @@ #include "iceoryx_posh/popo/client.hpp" #include "iceoryx_posh/popo/wait_set.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include diff --git a/iceoryx_examples/request_response/server_cxx_basic.cpp b/iceoryx_examples/request_response/server_cxx_basic.cpp index 3772ce86ef..322a63a886 100644 --- a/iceoryx_examples/request_response/server_cxx_basic.cpp +++ b/iceoryx_examples/request_response/server_cxx_basic.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/server.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -36,7 +36,7 @@ int main() //! [create server] //! [process requests in a loop] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { //! [take request] server.take().and_then([&](const auto& request) { diff --git a/iceoryx_examples/request_response/server_cxx_listener.cpp b/iceoryx_examples/request_response/server_cxx_listener.cpp index 62ca9d492f..96d87ab025 100644 --- a/iceoryx_examples/request_response/server_cxx_listener.cpp +++ b/iceoryx_examples/request_response/server_cxx_listener.cpp @@ -20,7 +20,7 @@ #include "iceoryx_posh/popo/listener.hpp" #include "iceoryx_posh/popo/server.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -76,7 +76,7 @@ int main() //! [attach listener] //! [wait for termination] - iox::waitForTerminationRequest(); + iox::posix::waitForTerminationRequest(); //! [wait for termination] //! [cleanup] diff --git a/iceoryx_examples/request_response/server_cxx_untyped.cpp b/iceoryx_examples/request_response/server_cxx_untyped.cpp index 651a30a659..577a1ce8c6 100644 --- a/iceoryx_examples/request_response/server_cxx_untyped.cpp +++ b/iceoryx_examples/request_response/server_cxx_untyped.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/untyped_server.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -36,7 +36,7 @@ int main() //! [create server] //! [process requests in a loop] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { //! [take request] server.take().and_then([&](auto& requestPayload) { diff --git a/iceoryx_examples/singleprocess/single_process.cpp b/iceoryx_examples/singleprocess/single_process.cpp index f4ae89f5fb..626821e1b2 100644 --- a/iceoryx_examples/singleprocess/single_process.cpp +++ b/iceoryx_examples/singleprocess/single_process.cpp @@ -24,7 +24,7 @@ #include "iceoryx_posh/runtime/posh_runtime_single_process.hpp" #include "iox/detail/convert.hpp" #include "iox/logging.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include #include @@ -59,7 +59,7 @@ void publisher() //! [send] uint64_t counter{0}; constexpr const char GREEN_RIGHT_ARROW[] = "\033[32m->\033[m "; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { publisher.loan().and_then([&](auto& sample) { sample->counter = counter++; @@ -83,7 +83,7 @@ void subscriber() //! [receive] constexpr const char ORANGE_LEFT_ARROW[] = "\033[33m<-\033[m "; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { if (iox::SubscribeState::SUBSCRIBED == subscriber.getSubscriptionState()) { @@ -136,7 +136,7 @@ int main() //! [run] std::thread publisherThread(publisher), subscriberThread(subscriber); - iox::waitForTerminationRequest(); + iox::posix::waitForTerminationRequest(); publisherThread.join(); subscriberThread.join(); diff --git a/iceoryx_examples/user_header/publisher_cxx_api.cpp b/iceoryx_examples/user_header/publisher_cxx_api.cpp index 78599083af..6543a08d11 100644 --- a/iceoryx_examples/user_header/publisher_cxx_api.cpp +++ b/iceoryx_examples/user_header/publisher_cxx_api.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -40,7 +40,7 @@ int main() uint64_t timestamp = 42; uint64_t fibonacciLast = 0; uint64_t fibonacciCurrent = 1; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { auto fibonacciNext = fibonacciCurrent + fibonacciLast; fibonacciLast = fibonacciCurrent; diff --git a/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp b/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp index 02c4116daf..8aa4e66d95 100644 --- a/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp +++ b/iceoryx_examples/user_header/publisher_untyped_cxx_api.cpp @@ -17,7 +17,7 @@ //! [iceoryx includes] #include "user_header_and_payload_types.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [include differs from typed C++ API] #include "iceoryx_posh/popo/untyped_publisher.hpp" //! [include differs from typed C++ API] @@ -42,7 +42,7 @@ int main() uint64_t timestamp = 73; uint64_t fibonacciLast = 0; uint64_t fibonacciCurrent = 1; - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { auto fibonacciNext = fibonacciCurrent + fibonacciLast; fibonacciLast = fibonacciCurrent; diff --git a/iceoryx_examples/user_header/subscriber_cxx_api.cpp b/iceoryx_examples/user_header/subscriber_cxx_api.cpp index 74bb00d22b..886ce16806 100644 --- a/iceoryx_examples/user_header/subscriber_cxx_api.cpp +++ b/iceoryx_examples/user_header/subscriber_cxx_api.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -37,7 +37,7 @@ int main() //! [create subscriber] //! [poll subscriber for samples in a loop] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { //! [take sample] subscriber.take().and_then([&](auto& sample) { diff --git a/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp b/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp index 9272a3671f..51e41838c3 100644 --- a/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp +++ b/iceoryx_examples/user_header/subscriber_untyped_cxx_api.cpp @@ -19,7 +19,7 @@ #include "iceoryx_posh/popo/untyped_subscriber.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" //! [iceoryx includes] #include @@ -37,7 +37,7 @@ int main() //! [create subscriber] //! [poll subscriber for samples in a loop] - while (!iox::hasTerminationRequested()) + while (!iox::posix::hasTerminationRequested()) { //! [take chunk] subscriber.take().and_then([&](auto& userPayload) { diff --git a/iceoryx_examples/waitset/ice_waitset_publisher.cpp b/iceoryx_examples/waitset/ice_waitset_publisher.cpp index 4fcc03ac35..968e06163f 100644 --- a/iceoryx_examples/waitset/ice_waitset_publisher.cpp +++ b/iceoryx_examples/waitset/ice_waitset_publisher.cpp @@ -16,7 +16,7 @@ #include "iceoryx_posh/popo/publisher.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" #include "topic_data.hpp" #include @@ -27,7 +27,7 @@ void sending() iox::runtime::PoshRuntime::initRuntime("iox-cpp-publisher-waitset"); iox::popo::Publisher myPublisher({"Radar", "FrontLeft", "Counter"}); - for (uint32_t counter = 0U; !iox::hasTerminationRequested(); ++counter) + for (uint32_t counter = 0U; !iox::posix::hasTerminationRequested(); ++counter) { myPublisher.publishCopyOf(CounterTopic{counter}) .and_then([&] { std::cout << "Sending: " << counter << std::endl; }) diff --git a/iceoryx_hoofs/cmake/IceoryxPlatform.cmake b/iceoryx_hoofs/cmake/IceoryxPlatform.cmake index 5f143d95ef..293920bb46 100644 --- a/iceoryx_hoofs/cmake/IceoryxPlatform.cmake +++ b/iceoryx_hoofs/cmake/IceoryxPlatform.cmake @@ -80,7 +80,7 @@ function(iox_create_lsan_runtime_blacklist BLACKLIST_FILE_PATH) # count bytes template # 8 642 libacl.so.1 # 1 24 iox::posix::UnixDomainSocket::timedReceive - # 1 24 iox::MessageQueue::receive + # 1 24 iox::posix::MessageQueue::receive if(NOT EXISTS ${BLACKLIST_FILE_PATH}) file(WRITE ${BLACKLIST_FILE_PATH} "# This file is auto-generated from iceoryx_hoofs/cmake/IceoryxPlatform.cmake\n") file(APPEND ${BLACKLIST_FILE_PATH} "#leak:libacl.so.1\n") diff --git a/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp b/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp index b0ce97c127..461b1a417b 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/runtime/ipc_interface_base.hpp @@ -33,8 +33,8 @@ #include "iox/relative_pointer.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/unix_domain_socket.hpp" -#include "iox/message_queue.hpp" -#include "iox/named_pipe.hpp" +#include "iox/posix/message_queue.hpp" +#include "iox/posix/named_pipe.hpp" #include #include @@ -50,9 +50,9 @@ namespace iox namespace platform { #if defined(_WIN32) -using IoxIpcChannelType = iox::NamedPipe; +using IoxIpcChannelType = iox::posix::NamedPipe; #elif defined(__FREERTOS__) -using IoxIpcChannelType = iox::NamedPipe; +using IoxIpcChannelType = iox::posix::NamedPipe; #else using IoxIpcChannelType = iox::posix::UnixDomainSocket; #endif diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp index f309e8af47..e5e32bfe08 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp @@ -48,7 +48,7 @@ class RouDiApp protected: /// @brief waits for the next signal to RouDi daemon [[deprecated("in 3.0, removed in 4.0, use iox::posix::waitForTerminationRequest() from " - "'iox/signal_watcher.hpp'")]] bool + "'iox/posix/signal_watcher.hpp'")]] bool waitForSignal() noexcept; iox::log::LogLevel m_logLevel{iox::log::LogLevel::WARN}; diff --git a/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp b/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp index 55d4a7a2c3..5841e2eff8 100644 --- a/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp +++ b/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp @@ -20,8 +20,8 @@ #include "iceoryx_posh/internal/roudi/roudi.hpp" #include "iceoryx_posh/roudi/iceoryx_roudi_components.hpp" #include "iox/optional.hpp" +#include "iox/posix/signal_watcher.hpp" #include "iox/scoped_static.hpp" -#include "iox/signal_watcher.hpp" namespace iox { @@ -50,7 +50,7 @@ uint8_t IceOryxRouDiApp::run() noexcept m_compatibilityCheckLevel, m_processKillDelay, m_processTeminationDelay}); - iox::waitForTerminationRequest(); + iox::posix::waitForTerminationRequest(); } return EXIT_SUCCESS; } diff --git a/iceoryx_posh/source/roudi/application/roudi_app.cpp b/iceoryx_posh/source/roudi/application/roudi_app.cpp index 7a3987720e..9fd29f0e6f 100644 --- a/iceoryx_posh/source/roudi/application/roudi_app.cpp +++ b/iceoryx_posh/source/roudi/application/roudi_app.cpp @@ -25,7 +25,7 @@ #include "iceoryx_posh/roudi/cmd_line_args.hpp" #include "iox/logging.hpp" #include "iox/optional.hpp" -#include "iox/signal_watcher.hpp" +#include "iox/posix/signal_watcher.hpp" namespace iox { @@ -79,7 +79,7 @@ bool RouDiApp::checkAndOptimizeConfig(const RouDiConfig_t& config) noexcept bool RouDiApp::waitForSignal() noexcept { - iox::waitForTerminationRequest(); + iox::posix::waitForTerminationRequest(); return true; } diff --git a/iceoryx_posh/source/runtime/ipc_interface_base.cpp b/iceoryx_posh/source/runtime/ipc_interface_base.cpp index 7c505907ea..bb11b7f6e4 100644 --- a/iceoryx_posh/source/runtime/ipc_interface_base.cpp +++ b/iceoryx_posh/source/runtime/ipc_interface_base.cpp @@ -242,7 +242,7 @@ bool IpcInterface::ipcChannelMapsToFile() noexcept } template <> -bool IpcInterface::ipcChannelMapsToFile() noexcept +bool IpcInterface::ipcChannelMapsToFile() noexcept { return true; } @@ -263,8 +263,8 @@ void IpcInterface::cleanupOutdatedIpcChannel(const RuntimeName_t } template class IpcInterface; -template class IpcInterface; -template class IpcInterface; +template class IpcInterface; +template class IpcInterface; } // namespace runtime } // namespace iox diff --git a/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp b/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp index f8e71c48bc..24aa9d59e4 100644 --- a/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp +++ b/iceoryx_posh/test/integrationtests/test_mq_interface_startup_race.cpp @@ -22,7 +22,7 @@ #include "iceoryx_posh/internal/runtime/ipc_message.hpp" #include "iceoryx_posh/internal/runtime/ipc_runtime_interface.hpp" #include "iox/duration.hpp" -#include "iox/message_queue.hpp" +#include "iox/posix/message_queue.hpp" #include "iox/std_string_support.hpp" diff --git a/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp b/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp index 5ab99b5b22..77bbf6efed 100644 --- a/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp +++ b/iceoryx_posh/test/moduletests/test_runtime_ipc_interface.cpp @@ -18,8 +18,8 @@ #include "iceoryx_hoofs/internal/posix_wrapper/unix_domain_socket.hpp" #include "iceoryx_platform/platform_settings.hpp" #include "iceoryx_posh/internal/runtime/ipc_interface_base.hpp" -#include "iox/message_queue.hpp" -#include "iox/named_pipe.hpp" +#include "iox/posix/message_queue.hpp" +#include "iox/posix/named_pipe.hpp" #include "iox/std_chrono_support.hpp" #include "test.hpp" From 7b5cd753ec4fe1c3dd86642cf238bcea53fc7ed5 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 9 Nov 2023 17:56:40 +0100 Subject: [PATCH 09/12] iox-#1391 Use IOX_DEPRECATED_SINCE where appropriate --- iceoryx_hoofs/vocabulary/include/iox/expected.hpp | 7 ++++--- .../include/iceoryx_posh/roudi/roudi_app.hpp | 6 +++--- .../roudi_environment/roudi_environment.hpp | 15 +++++++-------- .../include/iceoryx_posh/testing/roudi_gtest.hpp | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp index 12f4a529b4..f4d026070b 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp @@ -18,6 +18,7 @@ #define IOX_HOOFS_VOCABULARY_EXPECTED_HPP #include "iox/attributes.hpp" +#include "iox/detail/deprecation_marker.hpp" #include "iox/detail/expected_helper.hpp" #include "iox/functional_interface.hpp" #include "iox/optional.hpp" @@ -243,15 +244,15 @@ class IOX_NO_DISCARD expected final : public FunctionalInterface @@ -47,9 +48,8 @@ class RouDiApp protected: /// @brief waits for the next signal to RouDi daemon - [[deprecated("in 3.0, removed in 4.0, use iox::posix::waitForTerminationRequest() from " - "'iox/posix/signal_watcher.hpp'")]] bool - waitForSignal() noexcept; + IOX_DEPRECATED_SINCE(3, "Please use iox::posix::waitForTerminationRequest() from 'iox/posix/signal_watcher.hpp'") + bool waitForSignal() noexcept; iox::log::LogLevel m_logLevel{iox::log::LogLevel::WARN}; roudi::MonitoringMode m_monitoringMode{roudi::MonitoringMode::ON}; diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp index 142081490c..594842ec98 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_environment/roudi_environment.hpp @@ -19,6 +19,7 @@ #define IOX_POSH_ROUDI_ENVIRONMENT_ROUDI_ENVIRONMENT_HPP #include "iceoryx_posh/roudi_env/roudi_env.hpp" +#include "iox/detail/deprecation_marker.hpp" #include @@ -27,8 +28,7 @@ namespace iox namespace roudi { /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'iox::roudi_env::RouDiEnv' -class [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'iox::roudi_env::RouDiEnv'")]] RouDiEnvironment - : public roudi_env::RouDiEnv +class IOX_DEPRECATED_SINCE(3, "Please port to 'iox::roudi_env::RouDiEnv'") RouDiEnvironment : public roudi_env::RouDiEnv { public: using ParentType = roudi_env::RouDiEnv; @@ -36,22 +36,21 @@ class [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'iox::roud using ParentType::operator=; /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout' - [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout'")]] void - SetInterOpWaitingTime(const std::chrono::milliseconds& v) noexcept + IOX_DEPRECATED_SINCE(3, "Please port to 'setDiscoveryLoopWaitToFinishTimeout'") + void SetInterOpWaitingTime(const std::chrono::milliseconds& v) noexcept { setDiscoveryLoopWaitToFinishTimeout(units::Duration::fromMilliseconds(v.count())); } /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish' - [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish'")]] void - InterOpWait() noexcept + IOX_DEPRECATED_SINCE(3, "Please port to 'triggerDiscoveryLoopAndWaitToFinish'") void InterOpWait() noexcept { triggerDiscoveryLoopAndWaitToFinish(); } /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources' - [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources'")]] void CleanupAppResources( - const RuntimeName_t& name) noexcept + IOX_DEPRECATED_SINCE(3, "Please port to 'cleanupAppResources'") + void CleanupAppResources(const RuntimeName_t& name) noexcept { cleanupAppResources(name); } diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp index 50a6dea74a..ccf8dd5bef 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/roudi_gtest.hpp @@ -18,6 +18,7 @@ #define IOX_POSH_TESTUTILS_ROUDI_GTEST_HPP #include "iceoryx_posh/roudi_env/roudi_env.hpp" +#include "iox/detail/deprecation_marker.hpp" #include #include @@ -33,16 +34,15 @@ class RouDi_GTest : public iox::roudi_env::RouDiEnv, public ::testing::Test RouDi_GTest(const iox::RouDiConfig_t& roudiConfig) noexcept; /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout' - [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'setDiscoveryLoopWaitToFinishTimeout'")]] void - SetInterOpWaitingTime(const std::chrono::milliseconds& v) noexcept; + IOX_DEPRECATED_SINCE(3, "Please port to 'setDiscoveryLoopWaitToFinishTimeout'") + void SetInterOpWaitingTime(const std::chrono::milliseconds& v) noexcept; /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish' - [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'triggerDiscoveryLoopAndWaitToFinish'")]] void - InterOpWait() noexcept; + IOX_DEPRECATED_SINCE(3, "Please port to 'triggerDiscoveryLoopAndWaitToFinish'") void InterOpWait() noexcept; /// @deprecated Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources' - [[deprecated("Deprecated in 3.0, removed in 4.0, please port to 'cleanupAppResources'")]] void - CleanupAppResources(const RuntimeName_t& name) noexcept; + IOX_DEPRECATED_SINCE(3, "Please port to 'cleanupAppResources'") + void CleanupAppResources(const RuntimeName_t& name) noexcept; }; } // namespace testing From 4c83ae8663a27acd8931a21d9d5a1515716bf201 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 9 Nov 2023 18:12:20 +0100 Subject: [PATCH 10/12] iox-#2011 Restrict cirrus-ci to specific branches --- .cirrus.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.cirrus.yaml b/.cirrus.yaml index cd896d4982..06d8fc96fe 100644 --- a/.cirrus.yaml +++ b/.cirrus.yaml @@ -12,6 +12,18 @@ --- +# +# Filter to run the CI only on the master and release branches or for pull request to the master, release* and iox-* branches +# + +only_if: $CIRRUS_BRANCH == 'master' + || $CIRRUS_BRANCH == 'release*' + || ($CIRRUS_PR != '' && ($CIRRUS_BASE_BRANCH == 'master' + || $CIRRUS_BASE_BRANCH == 'release*' + || $CIRRUS_BASE_BRANCH == 'iox-*' + ) + ) + # # Templates # From 19b7623563ce32aef2bcd211be941becc06a49d0 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 9 Nov 2023 18:32:15 +0100 Subject: [PATCH 11/12] iox-#1391 Add misra.org.uk to the link checker ignore list It seems cloudfare introduced some checks which make the link checker fail --- .lycheeignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.lycheeignore b/.lycheeignore index 89eb9f4b0e..fba2101f45 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -1,4 +1,5 @@ https://github.com/eclipse-iceoryx/iceoryx/compare/vx.x.x...vx.x.x https://github.com/eclipse-iceoryx/iceoryx/tree/vx.x.x +https://www.misra.org.uk/ iceoryx-dev@eclipse.org From 6f6a714c6b48a78fa6c9d58cb1268e144c3bc4e8 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 9 Nov 2023 20:54:40 +0100 Subject: [PATCH 12/12] iox-#1391 Fix 'PortUser_IntegrationTest' timeout on Windows --- .../test_popo_port_user_building_blocks.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp index a0176e15b1..31fcf6c8ca 100644 --- a/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp +++ b/iceoryx_posh/test/integrationtests/test_popo_port_user_building_blocks.cpp @@ -324,7 +324,12 @@ class PortUser_IntegrationTest : public Test ++i; /// Add some jitter to make thread breathe - std::this_thread::sleep_for(std::chrono::microseconds(100 + rand() % 50)); + /// On Windows even when asked for short sleeps the OS suspends the execution for multiple milliseconds; + /// therefore lets sleep only every second iteration + if (i % 2 == 0) + { + std::this_thread::sleep_for(std::chrono::microseconds(100 + rand() % 50)); + } } } };