diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 4cde701812..5b626fbe5e 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -81,58 +81,61 @@ #include "iceoryx_hoofs/design_pattern/builder.hpp" ``` -3. Replace `Semaphore` with `NamedSemaphore` and `UnnamedSemaphore` +3. `UnnamedSemaphore` replaces `Semaphore` with `CreateUnnamed*` option ```cpp // before - #include "iceoryx_hoofs/posix_wrapper/semaphore.hpp" + #include "iceoryx_hoofs/posix_wrapper/semaphore.hpp" - // named semaphore - auto semaphore = iox::posix::Semaphore::create(iox::posix::CreateNamedSemaphore, - "mySemaphoreName", - S_IRUSR | S_IWUSR, - 0); + auto semaphore = iox::posix::Semaphore::create(iox::posix::CreateUnnamedSingleProcessSemaphore, 0); + + // after + #include "iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp" + + iox::cxx::optional semaphore; + auto result = iox::posix::UnnamedSemaphoreBuilder() + .initialValue(0U) + .isInterProcessCapable(true) + .create(semaphore); + ``` - // unnamed semaphore - auto semaphore = iox::posix::Semaphore::create(iox::posix::CreateUnnamedSingleProcessSemaphore, 0); +4. `NamedSemaphore` replaces `Semaphore` with `CreateNamedSemaphore` option + ```cpp + // before + #include "iceoryx_hoofs/posix_wrapper/semaphore.hpp" + + auto semaphore = iox::posix::Semaphore::create(iox::posix::CreateNamedSemaphore, + "mySemaphoreName", + S_IRUSR | S_IWUSR, + 0); // after - // named semaphore - #include "iceoryx_hoofs/posix_wrapper/named_semaphore.hpp" - - iox::cxx::optional semaphore; - auto result = iox::posix::NamedSemaphoreBuilder() - .name("mySemaphoreName") - .openMode(iox::posix::OpenMode::OPEN_OR_CREATE) - .permissions(iox::cxx::perms::owner_all) - .initialValue(0U) - .create(semaphore); - - // unnamed semaphore - #include "iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp" - - iox::cxx::optional semaphore; - auto result = iox::posix::UnnamedSemaphoreBuilder() - .initialValue(0U) - .isInterProcessCapable(true) - .create(semaphore); + #include "iceoryx_hoofs/posix_wrapper/named_semaphore.hpp" + + iox::cxx::optional semaphore; + auto result = iox::posix::NamedSemaphoreBuilder() + .name("mySemaphoreName") + .openMode(iox::posix::OpenMode::OPEN_OR_CREATE) + .permissions(iox::cxx::perms::owner_all) + .initialValue(0U) + .create(semaphore); ``` -4. `RoudiApp::waitForSignal` is deprecated +5. `RoudiApp::waitForSignal` is deprecated ```cpp // before - // in my custom roudi app implementation - uint8_t MyCustomRoudiApp::run() noexcept { - // ... + //// in my custom roudi app implementation + uint8_t MyCustomRoudiApp::run() noexcept { + // ... - waitForSignal(); - } + waitForSignal(); + } // after - // in my custom roudi app implementation - uint8_t MyCustomRoudiApp::run() noexcept { - // ... + //// in my custom roudi app implementation + uint8_t MyCustomRoudiApp::run() noexcept { + // ... - iox::posix::waitForTerminationRequest(); - } + iox::posix::waitForTerminationRequest(); + } ``` diff --git a/iceoryx_hoofs/test/moduletests/test_posix_signal_watcher.cpp b/iceoryx_hoofs/test/moduletests/test_posix_signal_watcher.cpp index eed8ae5311..3a9d2ffc5f 100644 --- a/iceoryx_hoofs/test/moduletests/test_posix_signal_watcher.cpp +++ b/iceoryx_hoofs/test/moduletests/test_posix_signal_watcher.cpp @@ -99,7 +99,7 @@ void unblocksWhenSignalWasRaisedForWaiters(SignalWatcher_test& test, }); } - iox::cxx::internal::adaptive_wait().wait_loop([&] { return !isThreadStarted; }); + iox::cxx::internal::adaptive_wait().wait_loop([&] { return (isThreadStarted != numberOfWaiters); }); std::this_thread::sleep_for(test.waitingTime); diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp index 8dba56533c..b3f106258f 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/condition_variable_data.hpp @@ -42,7 +42,7 @@ struct ConditionVariableData RuntimeName_t m_runtimeName; std::atomic_bool m_toBeDestroyed{false}; std::atomic_bool m_activeNotifications[MAX_NUMBER_OF_NOTIFIERS]; - std::atomic_bool wasNotified{false}; + std::atomic_bool m_wasNotified{false}; }; } // namespace popo diff --git a/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp b/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp index c697958e6e..8c01d2c1af 100644 --- a/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp +++ b/iceoryx_posh/source/popo/building_blocks/condition_listener.cpp @@ -53,7 +53,7 @@ void ConditionListener::destroy() noexcept bool ConditionListener::wasNotified() const noexcept { - return getMembers()->wasNotified.load(std::memory_order_relaxed); + return getMembers()->m_wasNotified.load(std::memory_order_relaxed); } ConditionListener::NotificationVector_t ConditionListener::wait() noexcept @@ -110,7 +110,7 @@ ConditionListener::NotificationVector_t ConditionListener::waitImpl(const cxx::f void ConditionListener::reset(const uint64_t index) noexcept { getMembers()->m_activeNotifications[index].store(false, std::memory_order_relaxed); - getMembers()->wasNotified.store(false, std::memory_order_relaxed); + getMembers()->m_wasNotified.store(false, std::memory_order_relaxed); } const ConditionVariableData* ConditionListener::getMembers() const noexcept diff --git a/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp b/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp index 00953bd3df..2a7fdf3ded 100644 --- a/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp +++ b/iceoryx_posh/source/popo/building_blocks/condition_notifier.cpp @@ -37,7 +37,7 @@ ConditionNotifier::ConditionNotifier(ConditionVariableData& condVarDataRef, cons void ConditionNotifier::notify() noexcept { getMembers()->m_activeNotifications[m_notificationIndex].store(true, std::memory_order_release); - getMembers()->wasNotified.store(true, std::memory_order_relaxed); + getMembers()->m_wasNotified.store(true, std::memory_order_relaxed); getMembers()->semaphore->post().or_else( [](auto) { errorHandler(PoshError::POPO__CONDITION_NOTIFIER_SEMAPHORE_CORRUPT_IN_NOTIFY, ErrorLevel::FATAL); }); } diff --git a/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp b/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp index 00eeea5267..718bf7697c 100644 --- a/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp +++ b/iceoryx_posh/source/roudi/application/iceoryx_roudi_app.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2019 - 2020 by Robert Bosch GmbH. All rights reserved. -// Copyright (c) 2019 - 2020 by Apex.AI Inc. All rights reserved. +// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.