Skip to content

Commit f8c4e41

Browse files
committed
iox-#51: review findings
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
1 parent fbcb665 commit f8c4e41

File tree

8 files changed

+24
-38
lines changed

8 files changed

+24
-38
lines changed

iceoryx_posh/include/iceoryx_posh/internal/popo/base_port.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
#pragma once
1616

17-
#include "iceoryx_posh/internal/popo/base_port_data.hpp"
1817
#include "iceoryx_posh/iceoryx_posh_types.hpp"
18+
#include "iceoryx_posh/internal/popo/base_port_data.hpp"
1919

2020
namespace iox
2121
{
@@ -57,31 +57,32 @@ class BasePort
5757
operator bool() const;
5858

5959
/// @brief Reads Type of actual CaPro Port (sender/receiver...)
60-
/// @param Nothing
6160
/// @return m_portType Type of Port in struct BasePortType
6261
BasePortType getPortType() const noexcept;
6362

6463
/// @brief Reads Type of actual CaPro Port (sender/receiver...)
65-
/// @param Nothing
6664
/// @return m_portType Type of Port in struct BasePortType
6765
capro::ServiceDescription getCaProServiceDescription() const noexcept;
6866

6967
/// @brief Gets Application Name for the active port
70-
/// @param Nothing
7168
/// @return Application name as String
7269
cxx::CString100 getApplicationName() const noexcept;
7370

74-
7571
/// @brief Gets Interface Name for the active port
76-
/// @param Nothing
7772
/// @return Interface name as enum value
7873
Interfaces getInterface() const noexcept;
7974

8075
/// @brief Gets Id of thethe active port
81-
/// @param Nothing
8276
/// @return UniqueId name as Integer
8377
uint64_t getUniqueID() const noexcept;
8478

79+
/// @brief Indicate that this port can be destroyed
80+
void destroy() noexcept;
81+
82+
/// @brief Checks whether port can be destroyed
83+
/// @return true if it shall be destroyed, false if not
84+
bool toBeDestroyed() const noexcept;
85+
8586
protected:
8687
const MemberType_t* getMembers() const noexcept;
8788
MemberType_t* getMembers() noexcept;

iceoryx_posh/include/iceoryx_posh/internal/popo/base_port_data.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct BasePortData
7676

7777
static std::atomic<uint64_t> s_uniqueIdCounter;
7878
std::atomic<uint64_t> m_uniqueId{0};
79-
std::atomic_bool m_tobeDestroyed{false};
79+
std::atomic_bool m_toBeDestroyed{false};
8080

8181
iox::relative_ptr<runtime::RunnableData> m_runnable;
8282
};

iceoryx_posh/include/iceoryx_posh/internal/popo/receiver_port.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ class ReceiverPort : public BasePort
6666
void unsubscribe();
6767
bool isSubscribed() const;
6868
SubscribeState getSubscribeState() const;
69-
void destroy();
70-
bool tobeDestroyed() const;
7169

7270
// (only) from delivery FiFo to Cache
7371
virtual bool getChunk(const mepoo::ChunkHeader*& f_chunkHeader) noexcept;

iceoryx_posh/include/iceoryx_posh/internal/popo/sender_port.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ class SenderPort : public BasePort
4545
void freeChunk(mepoo::ChunkHeader* const chunkHeader);
4646
void activate();
4747
void deactivate();
48-
void destroy();
49-
bool tobeDestroyed() const;
5048
bool hasSubscribers();
5149
void forwardChunk(mepoo::SharedChunk chunk);
5250
MemberType_t::Throughput getThroughput() const;

iceoryx_posh/source/popo/base_port.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,15 @@ BasePort::operator bool() const
7474
return m_basePortDataPtr != nullptr;
7575
}
7676

77+
void BasePort::destroy() noexcept
78+
{
79+
getMembers()->m_toBeDestroyed.store(true, std::memory_order_relaxed);
80+
}
81+
82+
bool BasePort::toBeDestroyed() const noexcept
83+
{
84+
return getMembers()->m_toBeDestroyed.load(std::memory_order_relaxed);
85+
}
86+
7787
} // namespace popo
7888
} // namespace iox

iceoryx_posh/source/popo/receiver_port.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,6 @@ SubscribeState ReceiverPort::getSubscribeState() const
189189
return getMembers()->m_subscriptionState.load(std::memory_order_relaxed);
190190
}
191191

192-
void ReceiverPort::destroy()
193-
{
194-
getMembers()->m_tobeDestroyed.store(true, std::memory_order_relaxed);
195-
}
196-
197-
bool ReceiverPort::tobeDestroyed() const
198-
{
199-
return getMembers()->m_tobeDestroyed.load(std::memory_order_relaxed);
200-
}
201-
202-
203192
bool ReceiverPort::getChunk(const mepoo::ChunkHeader*& f_chunkHeader) noexcept
204193
{
205194
mepoo::SharedChunk l_chunk;

iceoryx_posh/source/popo/sender_port.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,6 @@ void SenderPort::deactivate()
298298
}
299299
}
300300

301-
void SenderPort::destroy()
302-
{
303-
getMembers()->m_tobeDestroyed.store(true, std::memory_order_relaxed);
304-
}
305-
306-
bool SenderPort::tobeDestroyed() const
307-
{
308-
return getMembers()->m_tobeDestroyed.load(std::memory_order_relaxed);
309-
}
310-
311301
bool SenderPort::hasSubscribers()
312302
{
313303
return getMembers()->m_receiverHandler.appContext().hasReceivers();

iceoryx_posh/source/roudi/shared_memory_manager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void SharedMemoryManager::handleSenderPorts()
118118
sendToAllMatchingInterfacePorts(caproMessage, l_senderPort.getInterface());
119119
}
120120
// check if we have to destroy this sender port
121-
if (l_senderPort.tobeDestroyed())
121+
if (l_senderPort.toBeDestroyed())
122122
{
123123
destroySenderPort(l_senderPortData);
124124
}
@@ -147,7 +147,7 @@ void SharedMemoryManager::handleReceiverPorts()
147147
}
148148
}
149149
// check if we have to destroy this sender port
150-
if (l_receiverPort.tobeDestroyed())
150+
if (l_receiverPort.toBeDestroyed())
151151
{
152152
destroyReceiverPort(l_receiverPortData);
153153
}
@@ -425,7 +425,7 @@ void SharedMemoryManager::destroySenderPort(SenderPortType::MemberType_t* const
425425
removeEntryFromServiceRegistry(serviceDescription.getServiceIDString(), serviceDescription.getInstanceIDString());
426426
senderPort.cleanup();
427427

428-
capro::CaproMessage message(capro::CaproMessageType::STOP_OFFER, serviceDescription);
428+
const capro::CaproMessage message(capro::CaproMessageType::STOP_OFFER, serviceDescription);
429429
m_portIntrospection.reportMessage(message);
430430

431431
sendToAllMatchingReceiverPorts(message, senderPort);
@@ -434,7 +434,7 @@ void SharedMemoryManager::destroySenderPort(SenderPortType::MemberType_t* const
434434
m_portIntrospection.removeSender(senderPort.getApplicationName(), serviceDescription);
435435

436436
// delete sender impl from list after StopOffer was processed
437-
MiddlewareShm* const shm = m_ShmInterface.getShmInterface();
437+
const auto shm = m_ShmInterface.getShmInterface();
438438
shm->m_senderPortMembers.erase(senderPortData);
439439
DEBUG_PRINTF("Destroyed SenderPortImpl\n");
440440
}
@@ -455,7 +455,7 @@ void SharedMemoryManager::destroyReceiverPort(ReceiverPortType::MemberType_t* co
455455
m_portIntrospection.removeReceiver(receiverPort.getApplicationName(), serviceDescription);
456456

457457
// delete receiver impl from list after unsubscribe was processed
458-
MiddlewareShm* const shm = m_ShmInterface.getShmInterface();
458+
const auto shm = m_ShmInterface.getShmInterface();
459459
shm->m_receiverPortMembers.erase(receiverPortData);
460460
DEBUG_PRINTF("Destroyed ReceiverPortImpl\n");
461461
}

0 commit comments

Comments
 (0)