Skip to content

Commit

Permalink
Shared-memory transport implementation (eProsima#992)
Browse files Browse the repository at this point in the history
* shared_mem_transport interface classes

* build errors solved

* Refs #6942. Send-refactor

* SharedMemTransport refactoring

* SharedMemTransportInterface removed

* SharedMemTransport interface v0.1

* fields added to SharedMemTransportDescriptor

* Shared Memory transport unit testing

* test outgoing port is open

* Refs #6486. SharedMemoryManager::Port::Readers are now Listeners.

* Refs #6942. SharedMemTransport receives LocatorsIterator

* Refs #7022. SharedMemManager integration

* Refs #7022. SharedMemTransport test pass

* Refs #7022. UUIDs generator.

* Refs #7022. Fix compilation on Windows.

* Refs #7022. Fix Tests in Windows.

* Refs #7114. Try clean port before open

* Refs #7114. Helloworld working with shared-memory transport

* Refs #7114. Healthy check mecanism

* Refs #7114. Example HelloWorldExampleSharedMem added.

* Refs #7114. Reliability tests added.

* Refs #7114. Traces added.

* Refs #7114. Code review.

* Refs #7114. memset when creating segment

* Refs #7114. XML profile for SharedMemTransport.

* Refs #7237. UUIDs performance improvements.

* Refs #7237. Bugfix in healthy_check mecanism.

* Refs #7237. Bugfix in SharedMemTest (Windows).

* Refs #7237: Add SHM best effort latency test

* Refs #7237. Compilation warning removed.

* Refs #7237. Simple throughput tests added to shared-mem and udpv4.

* Refs #7237. Avoid copy to shared-memory when destination locators empty.

* Refs #7237. dev/shm files clean-up

* Refs #7237. Interprocess notify asynchronous

* Refs #7237. Bugfix: Big data wasn't supported.

* Refs #7364. Big datagrams (>64K) support in RTPS layer.

* Refs #7364. Big samples in HelloWorldExampleSharedMem.

* Refs #7409 Fix: locator_kind not checked in SHM send.

* Refs #7409. Transport selection when SHM & UDP available.

* Refs #7409 Bugs fixed.

* Refs #7409. Fix UDP+SHM vs UDP.

* Refs #7409. recv_buffer_size for SHM decoupled from max_message_size.

* Refs #7409. HelloWorldExampleSharedMem configurable message size.

* Refs #7409. HelloWorldExampleSharedMem Both transports active.

* Refs #7409. Refactor SHMEM -> SHM.

* Refs #7409. Warning removal.

* Refs #7237. SHM Throughput test added to cmake.

* Refs #7237. SHM transport default_port_queue_capacity set to 512.

* Refs #7479. Warning removal.

* Refs #7479. SharedMem-RingBuffer tests added.

* Refs #7479. SharedMemTransportTests send-timeout 100(ms) => 100(us).

* Refs #7409. Max message size limits to 64KB when participant is secure.

* Refs #7479. SHM & Security blackbox tests added

* Refs #6558. Remove warnings & errors in Windows.

* Refs #6558. Remove errors for V140 toolset.

* Refs #6558. Disable some tests.

* Refs #6558. ShareMemTransportTests - log::Flush().

* Refs #6558. Clag warnings removed & more logError/Warning.

* Refs #6558. More clang warnings removed.

* Refs #6558. Refactor SHM.

* Refs #6558. Windows shared-memory environment initialization.

* Refs #6558. Fix compilation error on Linux, Mac.

* Refs #7479. SHM Blackbox tests.

* Refs #7479. NOMINMAX added for MSVC to avoid compilation errors.

* Refs #7479. Compilation error in MAC with clang solved.

* Refs #7479. Enable SHM Generic emulation on Windows & MAC.

* Refs #7479. Latency test reliable_shm added.

* Refs #7479. Remove inexplicable warning with VC(v140 toolset).

* Refs #7479. Remove valgrind errors.

* Refs #7237. Performance throughput improvement.

* Refs #7237. Performance Latency improvement.

* Refs #7237. Uncrustify.

* Refs #7237. Allocate Buffer node & data in only one allocation.

* Refs #7479. Fix SharedMemTest mutex busy deletion.

* Refs #7479 Fix Test:SHMTransportTests.dead_listener_port_recover.

* Refs #7699. Supporting SHM transport with secure participants.

* Refs #7699. Refactor & Windows compilation errors solved.

* Refs #6558. rtps_dump_file added to SharedMemTransportDescriptor.

* Refs #7684. max_message_size SHM 64K to improve latency.

* Refs #7684. maxMessageSize for SHM configurable in XML.

* Refs #7517. Requested changes applied.

* Refs #7517. Warnings fix.

* Refs #7856. SHM unit tests failing under valgrind.

* Refs #6558. Requested changes applied.

* Refs #7839. Packet hex dump to file for SHM transport.

* Refs #7839. Fix warnings & SHM dump_file test failure on MAC.

* Refs #6645. Valgrind suppression for sem_open added.

* Refs #6645. Fix CMake wrong path for some files of SharedMem unit tests.

* Refs #6645. Added --gen-suppressions=all

* Refs #7517. Removed unused method on ReaderProxyData.

* Refs #7517. Ignore shared memory locators from other vendors.

* Revert "Refs #6645. Added --gen-suppressions=all"

This reverts commit 8e5d72d.

Co-authored-by: Iker Luengo <[email protected]>
Co-authored-by: EduPonz <[email protected]>
Co-authored-by: Miguel Company <[email protected]>
  • Loading branch information
4 people authored Mar 24, 2020
1 parent 3bd209a commit 4ec3610
Show file tree
Hide file tree
Showing 100 changed files with 9,663 additions and 111 deletions.
2 changes: 2 additions & 0 deletions examples/C++/HelloWorldExampleSharedMem/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin
output
59 changes: 59 additions & 0 deletions examples/C++/HelloWorldExampleSharedMem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 2.8.12)

if(NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy(SET CMP0048 NEW)
endif()

project(HelloWorldExampleSharedMem)

# Find requirements
if(NOT fastcdr_FOUND)
find_package(fastcdr REQUIRED)
endif()

if(NOT foonathan_memory_FOUND)
find_package(foonathan_memory REQUIRED)
endif()

if(NOT fastrtps_FOUND)
find_package(fastrtps REQUIRED)
endif()

# Set C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11)
if(SUPPORTS_CXX11)
add_compile_options(-std=c++11)
else()
message(FATAL_ERROR "Compiler doesn't support C++11")
endif()
endif()

message(STATUS "Configuring HelloWorld example...")
file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CXX "*.cxx")
file(GLOB HELLOWORLD_EXAMPLE_SOURCES_CPP "*.cpp")

if(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

add_executable(HelloWorldExampleSharedMem ${HELLOWORLD_EXAMPLE_SOURCES_CXX} ${HELLOWORLD_EXAMPLE_SOURCES_CPP})
target_link_libraries(HelloWorldExampleSharedMem fastrtps fastcdr foonathan_memory)
install(TARGETS HelloWorldExampleSharedMem
RUNTIME DESTINATION examples/C++/HelloWorldExampleSharedMem/${BIN_INSTALL_DIR})
255 changes: 255 additions & 0 deletions examples/C++/HelloWorldExampleSharedMem/HelloWorld.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file HelloWorld.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/

#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace { char dummy; }
#endif

#include "HelloWorld.h"
#include <fastcdr/Cdr.h>

#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;

#include <utility>

HelloWorld::HelloWorld()
{
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@185d8b6
m_index = 0;
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@67784306
m_message ="";
// m_data com.eprosima.idl.parser.typecode.ArrayTypeCode@335eadca
memset(&m_data, 0, DATA_SIZE);

}

HelloWorld::~HelloWorld()
{
}

HelloWorld::HelloWorld(
const HelloWorld& x)
{
m_index = x.m_index;
m_message = x.m_message;
m_data = x.m_data;
}

HelloWorld::HelloWorld(
HelloWorld&& x)
{
m_index = x.m_index;
m_message = std::move(x.m_message);
m_data = std::move(x.m_data);
}

HelloWorld& HelloWorld::operator=(
const HelloWorld& x)
{

m_index = x.m_index;
m_message = x.m_message;
m_data = x.m_data;

return *this;
}

HelloWorld& HelloWorld::operator=(
HelloWorld&& x)
{

m_index = x.m_index;
m_message = std::move(x.m_message);
m_data = std::move(x.m_data);

return *this;
}

size_t HelloWorld::getMaxCdrSerializedSize(
size_t current_alignment)
{
size_t initial_alignment = current_alignment;


current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);

current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1;

current_alignment += ((DATA_SIZE) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);

return current_alignment - initial_alignment;
}

size_t HelloWorld::getCdrSerializedSize(
const HelloWorld& data,
size_t current_alignment)
{
(void)data;
size_t initial_alignment = current_alignment;

current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);

current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1;

current_alignment += DATA_SIZE + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);

return current_alignment - initial_alignment;
}

void HelloWorld::serialize(
eprosima::fastcdr::Cdr& scdr) const
{
scdr << m_index;
scdr << m_message;
scdr << m_data;
}

void HelloWorld::deserialize(
eprosima::fastcdr::Cdr& dcdr)
{
dcdr >> m_index;
dcdr >> m_message;
dcdr >> m_data;
}

/*!
* @brief This function sets a value in member index
* @param _index New value for member index
*/
void HelloWorld::index(
uint32_t _index)
{
m_index = _index;
}

/*!
* @brief This function returns the value of member index
* @return Value of member index
*/
uint32_t HelloWorld::index() const
{
return m_index;
}

/*!
* @brief This function returns a reference to member index
* @return Reference to member index
*/
uint32_t& HelloWorld::index()
{
return m_index;
}

/*!
* @brief This function copies the value in member message
* @param _message New value to be copied in member message
*/
void HelloWorld::message(
const std::string& _message)
{
m_message = _message;
}

/*!
* @brief This function moves the value in member message
* @param _message New value to be moved in member message
*/
void HelloWorld::message(
std::string&& _message)
{
m_message = std::move(_message);
}

/*!
* @brief This function returns a constant reference to member message
* @return Constant reference to member message
*/
const std::string& HelloWorld::message() const
{
return m_message;
}

/*!
* @brief This function returns a reference to member message
* @return Reference to member message
*/
std::string& HelloWorld::message()
{
return m_message;
}
/*!
* @brief This function copies the value in member data
* @param _data New value to be copied in member data
*/
void HelloWorld::data(
const std::array<char, DATA_SIZE>& _data)
{
m_data = _data;
}

/*!
* @brief This function moves the value in member data
* @param _data New value to be moved in member data
*/
void HelloWorld::data(
std::array<char, DATA_SIZE>&& _data)
{
m_data = std::move(_data);
}

/*!
* @brief This function returns a constant reference to member data
* @return Constant reference to member data
*/
const std::array<char, DATA_SIZE>& HelloWorld::data() const
{
return m_data;
}

/*!
* @brief This function returns a reference to member data
* @return Reference to member data
*/
std::array<char, DATA_SIZE>& HelloWorld::data()
{
return m_data;
}

size_t HelloWorld::getKeyMaxCdrSerializedSize(
size_t current_alignment)
{
size_t current_align = current_alignment;

return current_align;
}

bool HelloWorld::isKeyDefined()
{
return false;
}

void HelloWorld::serializeKey(
eprosima::fastcdr::Cdr& scdr) const
{
(void) scdr;
}
Loading

0 comments on commit 4ec3610

Please sign in to comment.