Skip to content

Commit

Permalink
iox-eclipse-iceoryx#751 Renaming, update copyright year, improve code…
Browse files Browse the repository at this point in the history
… readability

Signed-off-by: Christian Eltzschig <me@elchris.org>
  • Loading branch information
elfenpiff committed Jun 23, 2022
1 parent 7a32fdd commit 3513d5f
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions iceoryx_binding_c/test/moduletests/test_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void notifyClient(ClientPortData& portData)
portData.m_connectionState = iox::ConnectionState::CONNECTED;
iox::popo::ChunkQueuePusher<ClientChunkQueueData_t> pusher{&portData.m_chunkReceiverData};
pusher.push(iox::mepoo::SharedChunk());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error());
}

TIMING_TEST_F(iox_listener_test, NotifyingClientEventWorks, Repeat(5), [&] {
Expand Down Expand Up @@ -491,7 +491,7 @@ void notifyServer(ServerPortData& portData)
{
iox::popo::ChunkQueuePusher<ServerChunkQueueData_t> pusher{&portData.m_chunkReceiverData};
pusher.push(iox::mepoo::SharedChunk());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error());
}

TEST_F(iox_listener_test, AttachingServerWorks)
Expand Down
6 changes: 3 additions & 3 deletions iceoryx_binding_c/test/moduletests/test_wait_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ void notifyClient(ClientPortData& portData)
portData.m_connectionState = iox::ConnectionState::CONNECTED;
iox::popo::ChunkQueuePusher<ClientChunkQueueData_t> pusher{&portData.m_chunkReceiverData};
pusher.push(iox::mepoo::SharedChunk());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error());
}

TEST_F(iox_ws_test, NotifyingClientEventWorks)
Expand Down Expand Up @@ -928,7 +928,7 @@ void notifyServer(ServerPortData& portData)
{
iox::popo::ChunkQueuePusher<ServerChunkQueueData_t> pusher{&portData.m_chunkReceiverData};
pusher.push(iox::mepoo::SharedChunk());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error());
}

TEST_F(iox_ws_test, AttachingServerEventWorks)
Expand Down Expand Up @@ -1140,7 +1140,7 @@ void notifyServiceDiscovery(SubscriberPortData& portData)
{
iox::popo::ChunkQueuePusher<SubscriberChunkReceiverData_t> pusher{&portData.m_chunkReceiverData};
pusher.push(iox::mepoo::SharedChunk());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->semaphore->post().has_error());
EXPECT_FALSE(portData.m_chunkReceiverData.m_conditionVariableDataPtr->m_semaphore->post().has_error());
}

TEST_F(iox_ws_test, NotifyingServiceDiscoveryEventWorks)
Expand Down
1 change: 1 addition & 0 deletions iceoryx_examples/request_response_in_c/client_c_waitset.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>

#define NUMBER_OF_NOTIFICATIONS 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "iceoryx_hoofs/cxx/type_traits.hpp"
#include "iceoryx_hoofs/platform/unistd.hpp"

#include <cstring>
#include <utility>

namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ class NamedPipe : public DesignPattern::Creation<NamedPipe, IpcChannelError>
// increased as long as there is enough memory available
static constexpr uint64_t MAX_MESSAGE_SIZE = 4U * 1024U;
static constexpr uint32_t MAX_NUMBER_OF_MESSAGES = 10U;
static_assert(
MAX_NUMBER_OF_MESSAGES < IOX_SEM_VALUE_MAX,
"The maximum number of supported messages must be less or equal to the maximum allowed semaphore value");
static_assert(MAX_NUMBER_OF_MESSAGES < IOX_SEM_VALUE_MAX,
"The maximum number of supported messages must be less to the maximum allowed semaphore value");

static constexpr uint64_t NULL_TERMINATOR_SIZE = 0U;
static constexpr units::Duration CYCLE_TIME = units::Duration::fromMilliseconds(10);
Expand Down
3 changes: 2 additions & 1 deletion iceoryx_hoofs/source/posix_wrapper/signal_watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ void internalSignalHandler(int) noexcept
// we use write since internalSignalHandler can be called from within a
// signal handler and write is signal safe
constexpr const char MSG[] = "Unable to increment semaphore in signal handler";
auto result = write(STDERR_FILENO, &MSG[0], strlen(&MSG[0]));
auto result = write(STDERR_FILENO, MSG, strlen(MSG));
IOX_DISCARD_RESULT(result);
std::abort();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ConditionListener
ConditionVariableData* getMembers() noexcept;

private:
void reset(const uint64_t index) noexcept;
void resetUnchecked(const uint64_t index) noexcept;
void resetSemaphore() noexcept;

NotificationVector_t waitImpl(const cxx::function_ref<bool()>& waitCall) noexcept;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 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.
Expand Down Expand Up @@ -38,7 +38,7 @@ struct ConditionVariableData
ConditionVariableData& operator=(ConditionVariableData&& rhs) = delete;
~ConditionVariableData() noexcept = default;

cxx::optional<posix::UnnamedSemaphore> semaphore;
cxx::optional<posix::UnnamedSemaphore> m_semaphore;
RuntimeName_t m_runtimeName;
std::atomic_bool m_toBeDestroyed{false};
std::atomic_bool m_activeNotifications[MAX_NUMBER_OF_NOTIFIERS];
Expand Down
14 changes: 7 additions & 7 deletions iceoryx_posh/source/popo/building_blocks/condition_listener.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 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.
Expand Down Expand Up @@ -33,7 +33,7 @@ void ConditionListener::resetSemaphore() noexcept
bool hasFatalError = false;
while (!hasFatalError
&& getMembers()
->semaphore->tryWait()
->m_semaphore->tryWait()
.or_else([&](posix::SemaphoreError) {
errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_RESET, ErrorLevel::FATAL);
hasFatalError = true;
Expand All @@ -46,7 +46,7 @@ void ConditionListener::resetSemaphore() noexcept
void ConditionListener::destroy() noexcept
{
m_toBeDestroyed.store(true, std::memory_order_relaxed);
getMembers()->semaphore->post().or_else([](auto) {
getMembers()->m_semaphore->post().or_else([](auto) {
errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_DESTROY, ErrorLevel::FATAL);
});
}
Expand All @@ -59,7 +59,7 @@ bool ConditionListener::wasNotified() const noexcept
ConditionListener::NotificationVector_t ConditionListener::wait() noexcept
{
return waitImpl([this]() -> bool {
if (this->getMembers()->semaphore->wait().has_error())
if (this->getMembers()->m_semaphore->wait().has_error())
{
errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_WAIT, ErrorLevel::FATAL);
return false;
Expand All @@ -71,7 +71,7 @@ ConditionListener::NotificationVector_t ConditionListener::wait() noexcept
ConditionListener::NotificationVector_t ConditionListener::timedWait(const units::Duration& timeToWait) noexcept
{
return waitImpl([this, timeToWait]() -> bool {
if (this->getMembers()->semaphore->timedWait(timeToWait).has_error())
if (this->getMembers()->m_semaphore->timedWait(timeToWait).has_error())
{
errorHandler(PoshError::POPO__CONDITION_LISTENER_SEMAPHORE_CORRUPTED_IN_TIMED_WAIT, ErrorLevel::FATAL);
}
Expand All @@ -92,7 +92,7 @@ ConditionListener::NotificationVector_t ConditionListener::waitImpl(const cxx::f
{
if (getMembers()->m_activeNotifications[i].load(std::memory_order_relaxed))
{
reset(i);
resetUnchecked(i);
activeNotifications.emplace_back(i);
}
}
Expand All @@ -107,7 +107,7 @@ ConditionListener::NotificationVector_t ConditionListener::waitImpl(const cxx::f
return activeNotifications;
}

void ConditionListener::reset(const uint64_t index) noexcept
void ConditionListener::resetUnchecked(const uint64_t index) noexcept
{
getMembers()->m_activeNotifications[index].store(false, std::memory_order_relaxed);
getMembers()->m_wasNotified.store(false, std::memory_order_relaxed);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 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.
Expand Down Expand Up @@ -38,7 +38,7 @@ void ConditionNotifier::notify() noexcept
{
getMembers()->m_activeNotifications[m_notificationIndex].store(true, std::memory_order_release);
getMembers()->m_wasNotified.store(true, std::memory_order_relaxed);
getMembers()->semaphore->post().or_else(
getMembers()->m_semaphore->post().or_else(
[](auto) { errorHandler(PoshError::POPO__CONDITION_NOTIFIER_SEMAPHORE_CORRUPT_IN_NOTIFY, ErrorLevel::FATAL); });
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2021 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.
Expand Down Expand Up @@ -29,7 +29,7 @@ ConditionVariableData::ConditionVariableData() noexcept
ConditionVariableData::ConditionVariableData(const RuntimeName_t& runtimeName) noexcept
: m_runtimeName(runtimeName)
{
posix::UnnamedSemaphoreBuilder().initialValue(0U).isInterProcessCapable(true).create(semaphore).or_else([](auto) {
posix::UnnamedSemaphoreBuilder().initialValue(0U).isInterProcessCapable(true).create(m_semaphore).or_else([](auto) {
errorHandler(PoshError::POPO__CONDITION_VARIABLE_DATA_FAILED_TO_CREATE_SEMAPHORE, ErrorLevel::FATAL);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 - 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.
Expand Down

0 comments on commit 3513d5f

Please sign in to comment.