Skip to content

Commit

Permalink
iox-eclipse-iceoryx#605 add subnamespace iox::rp
Browse files Browse the repository at this point in the history
Signed-off-by: Marika Lehmann <[email protected]>
  • Loading branch information
FerdinandSpitzschnueffler committed Mar 15, 2021
1 parent 0b7aef9 commit 9618538
Show file tree
Hide file tree
Showing 46 changed files with 190 additions and 150 deletions.
2 changes: 1 addition & 1 deletion doc/conceptual-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Memory chunks are returned to the pool once all attached `SubscriberPort`s indic
### A Note on Pointers
As already discussed, shared memory segments may be mapped to different memory areas in the virtual address space of a
process.
To deal with this, iceoryx utilizes specialized pointer types: the `iox::RelativePointer` and
To deal with this, iceoryx utilizes specialized pointer types: the `iox::rp::RelativePointer` and
the `iox::RelocatablePointer`.

Using these types, the difference in memory mapping is not a factor when it comes to locating a memory chunk.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ struct alignas(32) ChunkManagement
{
}

iox::RelativePointer<base_t> m_chunkHeader;
iox::rp::RelativePointer<base_t> m_chunkHeader;
referenceCounter_t m_referenceCounter{1u};
/// @todo optimization: check if this can be replaced by an offset relative to the this pointer
iox::RelativePointer<MemPool> m_mempool;
iox::RelativePointer<MemPool> m_chunkManagementPool;
iox::rp::RelativePointer<MemPool> m_mempool;
iox::rp::RelativePointer<MemPool> m_chunkManagementPool;
};
} // namespace mepoo
} // namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class MemPool
void adjustMinFree();
bool isMultipleOfAlignment(const uint32_t value) const;

RelativePointer<uint8_t> m_rawMemory;
rp::RelativePointer<uint8_t> m_rawMemory;

uint32_t m_chunkSize{0u};
/// needs to be 32 bit since loffli supports only 32 bit numbers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ inline SharedMemoryObjectType MePooSegment<SharedMemoryObjectType, MemoryManager
BASE_ADDRESS_HINT,
static_cast<mode_t>(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
.and_then([this](auto& sharedMemoryObject) {
setSegmentId(iox::BaseRelativePointer::registerPtr(sharedMemoryObject.getBaseAddress(),
sharedMemoryObject.getSizeInBytes()));
setSegmentId(iox::rp::BaseRelativePointer::registerPtr(sharedMemoryObject.getBaseAddress(),
sharedMemoryObject.getSizeInBytes()));

LogDebug() << "Roudi registered payload segment "
<< iox::log::HexFormat(reinterpret_cast<uint64_t>(sharedMemoryObject.getBaseAddress()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SharedChunk
public:
SharedChunk() = default;
SharedChunk(ChunkManagement* const f_resource);
SharedChunk(const RelativePointer<ChunkManagement>& f_resource);
SharedChunk(const rp::RelativePointer<ChunkManagement>& f_resource);
~SharedChunk();

SharedChunk(const SharedChunk& rhs);
Expand All @@ -48,7 +48,7 @@ class SharedChunk
void* getPayload() const;

ChunkManagement* release();
iox::RelativePointer<ChunkManagement> releaseWithRelativePtr();
iox::rp::RelativePointer<ChunkManagement> releaseWithRelativePtr();

bool operator==(const SharedChunk& rhs) const;
/// @todo use the newtype pattern to avoid the void pointer
Expand All @@ -70,7 +70,7 @@ class SharedChunk
void freeChunk();

private:
iox::RelativePointer<ChunkManagement> m_chunkManagement;
iox::rp::RelativePointer<ChunkManagement> m_chunkManagement;
};
} // namespace mepoo
} // namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ChunkDistributor<ChunkDistributorDataType>::tryAddQueue(cxx::not_null<ChunkQueue
if (getMembers()->m_queues.size() < getMembers()->m_queues.capacity())
{
// PRQA S 3804 1 # we checked the capacity, so pushing will be fine
getMembers()->m_queues.push_back(RelativePointer<ChunkQueueData_t>(queueToAdd));
getMembers()->m_queues.push_back(rp::RelativePointer<ChunkQueueData_t>(queueToAdd));

const auto currChunkHistorySize = getMembers()->m_history.size();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct ChunkDistributorData : public LockingPolicy
const uint64_t m_historyCapacity;

using QueueContainer_t =
cxx::vector<RelativePointer<ChunkQueueData_t>, ChunkDistributorDataProperties_t::MAX_QUEUES>;
cxx::vector<rp::RelativePointer<ChunkQueueData_t>, ChunkDistributorDataProperties_t::MAX_QUEUES>;
QueueContainer_t m_queues;

/// @todo using ChunkManagement instead of SharedChunk as in UsedChunkList?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ChunkQueueData : public LockingPolicy
cxx::VariantQueue<ChunkTuple, MAX_CAPACITY> m_queue;
std::atomic_bool m_queueHasOverflown{false};

RelativePointer<ConditionVariableData> m_conditionVariableDataPtr{nullptr};
rp::RelativePointer<ConditionVariableData> m_conditionVariableDataPtr{nullptr};
cxx::optional<uint64_t> m_eventVariableIndex;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ inline cxx::optional<mepoo::SharedChunk> ChunkQueuePopper<ChunkQueueDataType>::t
{
auto chunkTupleOut = *retVal;
auto chunkManagement =
RelativePointer<mepoo::ChunkManagement>(chunkTupleOut.m_chunkOffset, chunkTupleOut.m_segmentId);
rp::RelativePointer<mepoo::ChunkManagement>(chunkTupleOut.m_chunkOffset, chunkTupleOut.m_segmentId);
auto chunk = mepoo::SharedChunk(chunkManagement);
return cxx::make_optional<mepoo::SharedChunk>(chunk);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ inline void ChunkQueuePopper<ChunkQueueDataType>::clear() noexcept
// PRQA S 4117 4 # d'tor of SharedChunk will release the memory, so RAII has the side effect here
auto chunkTupleOut = maybeChunkTuple.value();
auto chunkManagement =
RelativePointer<mepoo::ChunkManagement>(chunkTupleOut.m_chunkOffset, chunkTupleOut.m_segmentId);
rp::RelativePointer<mepoo::ChunkManagement>(chunkTupleOut.m_chunkOffset, chunkTupleOut.m_segmentId);
auto chunk = mepoo::SharedChunk(chunkManagement);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline void ChunkQueuePusher<ChunkQueueDataType>::push(mepoo::SharedChunk chunk)
{
auto chunkTupleOut = pushRet.value();
auto chunkManagement =
RelativePointer<mepoo::ChunkManagement>(chunkTupleOut.m_chunkOffset, chunkTupleOut.m_segmentId);
rp::RelativePointer<mepoo::ChunkManagement>(chunkTupleOut.m_chunkOffset, chunkTupleOut.m_segmentId);
// this will release the chunk
auto returnedChunk = mepoo::SharedChunk(chunkManagement);
/// we have to set this to true to inform the higher levels that there
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ namespace popo
struct ChunkTuple
{
ChunkTuple() = default;
explicit ChunkTuple(RelativePointer<mepoo::ChunkManagement> f_chunk) noexcept;
explicit ChunkTuple(rp::RelativePointer<mepoo::ChunkManagement> f_chunk) noexcept;

BaseRelativePointer::id_t m_segmentId{BaseRelativePointer::NULL_POINTER_ID};
BaseRelativePointer::offset_t m_chunkOffset{BaseRelativePointer::NULL_POINTER_OFFSET};
rp::BaseRelativePointer::id_t m_segmentId{rp::BaseRelativePointer::NULL_POINTER_ID};
rp::BaseRelativePointer::offset_t m_chunkOffset{rp::BaseRelativePointer::NULL_POINTER_OFFSET};
};

} // namespace popo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct ChunkSenderData : public ChunkDistributorDataType

using ChunkDistributorData_t = ChunkDistributorDataType;

const RelativePointer<mepoo::MemoryManager> m_memoryMgr;
const rp::RelativePointer<mepoo::MemoryManager> m_memoryMgr;
mepoo::MemoryInfo m_memoryInfo;
UsedChunkList<MaxChunksAllocatedSimultaneously> m_chunksInUse;
mepoo::SequenceNumber_t m_sequenceNumber{0U};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RPCBaseHeader
}

protected:
RelativePointer<ClientChunkQueueData_t> m_clientQueueDataPtr;
rp::RelativePointer<ClientChunkQueueData_t> m_clientQueueDataPtr;
int64_t m_sequenceNumber{0};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class UsedChunkList
uint32_t m_usedListHead{InvalidIndex};
uint32_t m_freeListHead{0u};
std::array<uint32_t, Size> m_list;
std::array<RelativePointer<mepoo::ChunkManagement>, Size> m_data;
std::array<rp::RelativePointer<mepoo::ChunkManagement>, Size> m_data;
};

} // namespace popo
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/include/iceoryx_posh/internal/roudi/roudi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class RouDi

void monitorAndDiscoveryUpdate();

cxx::GenericRAII m_unregisterRelativePtr{[] {}, [] { BaseRelativePointer::unregisterAll(); }};
cxx::GenericRAII m_unregisterRelativePtr{[] {}, [] { rp::BaseRelativePointer::unregisterAll(); }};
bool m_killProcessesInDestructor;
std::atomic_bool m_runThreads;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class ProcessManager : public ProcessManagerInterface
PortManager& m_portManager;
mepoo::SegmentManager<>* m_segmentManager{nullptr};
mepoo::MemoryManager* m_introspectionMemoryManager{nullptr};
BaseRelativePointer::id_t m_mgmtSegmentId{BaseRelativePointer::NULL_POINTER_ID};
rp::BaseRelativePointer::id_t m_mgmtSegmentId{rp::BaseRelativePointer::NULL_POINTER_ID};
mutable std::mutex m_mutex;

ProcessList_t m_processList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class IpcRuntimeInterface
bool sendMessageToRouDi(const IpcMessage& msg) noexcept;

/// @brief get the adress offset of the segment manager
/// @return address offset as BaseRelativePointer::offset_t
BaseRelativePointer::offset_t getSegmentManagerAddressOffset() const noexcept;
/// @return address offset as rp::BaseRelativePointer::offset_t
rp::BaseRelativePointer::offset_t getSegmentManagerAddressOffset() const noexcept;

/// @brief get the size of the management shared memory object
/// @return size in bytes
Expand All @@ -87,7 +87,7 @@ class IpcRuntimeInterface

private:
ProcessName_t m_appName;
cxx::optional<BaseRelativePointer::offset_t> m_segmentManagerAddressOffset;
cxx::optional<rp::BaseRelativePointer::offset_t> m_segmentManagerAddressOffset;
IpcInterfaceCreator m_AppIpcInterface;
IpcInterfaceUser m_RoudiIpcInterface;
uint64_t m_shmTopicSize{0U};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class SharedMemoryUser
SharedMemoryUser(const bool doMapSharedMemoryIntoThread,
const size_t topicSize,
const uint64_t segmentId,
const BaseRelativePointer::offset_t segmentManagerAddressOffset);
const rp::BaseRelativePointer::offset_t segmentManagerAddressOffset);

private:
void openDataSegments(const uint64_t segmentId,
const BaseRelativePointer::offset_t segmentManagerAddressOffset) noexcept;
const rp::BaseRelativePointer::offset_t segmentManagerAddressOffset) noexcept;

private:
cxx::optional<posix::SharedMemoryObject> m_shmObject;
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/source/mepoo/shared_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SharedChunk::SharedChunk(ChunkManagement* const f_resource)
{
}

SharedChunk::SharedChunk(const RelativePointer<ChunkManagement>& f_resource)
SharedChunk::SharedChunk(const rp::RelativePointer<ChunkManagement>& f_resource)
: m_chunkManagement(f_resource)
{
}
Expand Down Expand Up @@ -156,7 +156,7 @@ ChunkManagement* SharedChunk::release()
return returnValue;
}

iox::RelativePointer<ChunkManagement> SharedChunk::releaseWithRelativePtr()
iox::rp::RelativePointer<ChunkManagement> SharedChunk::releaseWithRelativePtr()
{
auto returnValue = m_chunkManagement;
m_chunkManagement = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace iox
{
namespace popo
{
ChunkTuple::ChunkTuple(iox::RelativePointer<mepoo::ChunkManagement> f_chunk) noexcept
ChunkTuple::ChunkTuple(iox::rp::RelativePointer<mepoo::ChunkManagement> f_chunk) noexcept
: m_segmentId(f_chunk.getId())
, m_chunkOffset(f_chunk.getOffset())
{
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/source/roudi/memory/memory_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ cxx::expected<MemoryProviderError> MemoryProvider::create() noexcept

m_memory = memoryResult.value();
m_size = totalSize;
m_segmentId = BaseRelativePointer::registerPtr(m_memory, m_size);
m_segmentId = rp::BaseRelativePointer::registerPtr(m_memory, m_size);

LogDebug() << "Registered memory segment " << iox::log::HexFormat(reinterpret_cast<uint64_t>(m_memory))
<< " with size " << m_size << " to id " << m_segmentId;
Expand Down Expand Up @@ -117,7 +117,7 @@ cxx::expected<MemoryProviderError> MemoryProvider::destroy() noexcept

if (!destructionResult.has_error())
{
BaseRelativePointer::unregisterPtr(m_segmentId);
rp::BaseRelativePointer::unregisterPtr(m_segmentId);
m_memory = nullptr;
m_size = 0u;
}
Expand Down
18 changes: 9 additions & 9 deletions iceoryx_posh/source/roudi/roudi_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ bool ProcessManager::addProcess(const ProcessName_t& name,
// send REG_ACK and BaseAddrString
runtime::IpcMessage sendBuffer;

auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, m_segmentManager);
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, m_segmentManager);
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::REG_ACK)
<< m_roudiMemoryInterface.mgmtMemoryProvider()->size() << offset << transmissionTimestamp
<< m_mgmtSegmentId;
Expand Down Expand Up @@ -516,7 +516,7 @@ void ProcessManager::addInterfaceForProcess(const ProcessName_t& name,
popo::InterfacePortData* port = m_portManager.acquireInterfacePortData(interface, name, node);

// send ReceiverPort to app as a serialized relative pointer
auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, port);
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, port);

runtime::IpcMessage sendBuffer;
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::CREATE_INTERFACE_ACK)
Expand All @@ -538,7 +538,7 @@ void ProcessManager::sendServiceRegistryChangeCounterToProcess(const ProcessName
if (nullptr != process)
{
// send counter to app as a serialized relative pointer
auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, m_portManager.serviceRegistryChangeCounter());
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, m_portManager.serviceRegistryChangeCounter());

runtime::IpcMessage sendBuffer;
sendBuffer << std::to_string(offset) << std::to_string(m_mgmtSegmentId);
Expand All @@ -559,7 +559,7 @@ void ProcessManager::addApplicationForProcess(const ProcessName_t& name) noexcep
{
popo::ApplicationPortData* port = m_portManager.acquireApplicationPortData(name);

auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, port);
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, port);

runtime::IpcMessage sendBuffer;
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::CREATE_APPLICATION_ACK)
Expand All @@ -583,7 +583,7 @@ void ProcessManager::addNodeForProcess(const ProcessName_t& processName, const N
{
m_portManager.acquireNodeData(processName, nodeName)
.and_then([&](auto nodeData) {
auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, nodeData);
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, nodeData);

runtime::IpcMessage sendBuffer;
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::CREATE_NODE_ACK)
Expand Down Expand Up @@ -645,7 +645,7 @@ void ProcessManager::addSubscriberForProcess(const ProcessName_t& name,
if (!maybeSubscriber.has_error())
{
// send SubscriberPort to app as a serialized relative pointer
auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, maybeSubscriber.value());
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, maybeSubscriber.value());

runtime::IpcMessage sendBuffer;
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::CREATE_SUBSCRIBER_ACK)
Expand Down Expand Up @@ -686,7 +686,7 @@ void ProcessManager::addPublisherForProcess(const ProcessName_t& name,
if (!maybePublisher.has_error())
{
// send PublisherPort to app as a serialized relative pointer
auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, maybePublisher.value());
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, maybePublisher.value());

runtime::IpcMessage sendBuffer;
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::CREATE_PUBLISHER_ACK)
Expand Down Expand Up @@ -723,7 +723,7 @@ void ProcessManager::addConditionVariableForProcess(const ProcessName_t& process
// Try to create a condition variable
m_portManager.acquireConditionVariableData(processName)
.and_then([&](auto condVar) {
auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, condVar);
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, condVar);

runtime::IpcMessage sendBuffer;
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::CREATE_CONDITION_VARIABLE_ACK)
Expand Down Expand Up @@ -761,7 +761,7 @@ void ProcessManager::addEventVariableForProcess(const ProcessName_t& processName
// Try to create an event variable
m_portManager.acquireEventVariableData(processName)
.and_then([&](auto condVar) {
auto offset = BaseRelativePointer::getOffset(m_mgmtSegmentId, condVar);
auto offset = rp::BaseRelativePointer::getOffset(m_mgmtSegmentId, condVar);

runtime::IpcMessage sendBuffer;
sendBuffer << runtime::IpcMessageTypeToString(runtime::IpcMessageType::CREATE_EVENT_VARIABLE_ACK)
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/source/runtime/ipc_runtime_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool IpcRuntimeInterface::sendKeepalive() noexcept
return m_RoudiIpcInterface.send({IpcMessageTypeToString(IpcMessageType::KEEPALIVE), m_appName});
}

BaseRelativePointer::offset_t IpcRuntimeInterface::getSegmentManagerAddressOffset() const noexcept
rp::BaseRelativePointer::offset_t IpcRuntimeInterface::getSegmentManagerAddressOffset() const noexcept
{
cxx::Ensures(m_segmentManagerAddressOffset.has_value()
&& "No segment manager available! Should have been fetched in the c'tor");
Expand Down Expand Up @@ -237,7 +237,7 @@ IpcRuntimeInterface::RegAckResult IpcRuntimeInterface::waitForRegAck(int64_t tra

// read out the shared memory base address and save it
iox::cxx::convert::fromString(receiveBuffer.getElementAtIndex(1U).c_str(), m_shmTopicSize);
BaseRelativePointer::offset_t offset{0U};
rp::BaseRelativePointer::offset_t offset{0U};
iox::cxx::convert::fromString(receiveBuffer.getElementAtIndex(2U).c_str(), offset);
m_segmentManagerAddressOffset.emplace(offset);

Expand Down
Loading

0 comments on commit 9618538

Please sign in to comment.