Skip to content

Commit

Permalink
Fix windows issue with flow controller example (#5142)
Browse files Browse the repository at this point in the history
* Refs #21469: Fix Debug build

Signed-off-by: Raúl Sánchez-Mateos Lizano <[email protected]>

* Refs #21469: Fix windows crash in flow controller example

Signed-off-by: Raúl Sánchez-Mateos Lizano <[email protected]>

* Refs #21469: Set extensibility explicitly

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #21469: Apply Mario's proposal

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: Raúl Sánchez-Mateos Lizano <[email protected]>
Signed-off-by: JesusPoderoso <[email protected]>
Co-authored-by: Raúl Sánchez-Mateos Lizano <[email protected]>
  • Loading branch information
JesusPoderoso and rsanchez15 authored Aug 8, 2024
1 parent d398b61 commit 817b14a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions examples/cpp/flow_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ target_compile_definitions(flow_control PRIVATE
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<STREQUAL:"${CMAKE_BUILD_TYPE}","Debug">>:__DEBUG>
$<$<BOOL:${INTERNAL_DEBUG}>:__INTERNALDEBUG> # Internal debug activated.
)
if(WIN32)
set_target_properties(flow_control PROPERTIES LINK_FLAGS /STACK:4194304)
endif()
target_link_libraries(flow_control fastdds fastcdr foonathan_memory)
install(TARGETS flow_control
RUNTIME DESTINATION ${DATA_INSTALL_DIR}/fastdds/examples/cpp/flow_control/${BIN_INSTALL_DIR})
Expand Down
1 change: 1 addition & 0 deletions examples/cpp/flow_control/FlowControl.idl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@extensibility(APPENDABLE)
struct FlowControl
{
unsigned long index;
Expand Down
7 changes: 7 additions & 0 deletions examples/cpp/flow_control/FlowControlTypeObjectSupport.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ void register_FlowControl_type_identifier(
QualifiedTypeName type_name_FlowControl = "FlowControl";
eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_FlowControl;
eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_FlowControl;
AppliedAnnotationSeq tmp_ann_custom_FlowControl;
eprosima::fastcdr::optional<AppliedVerbatimAnnotation> verbatim_FlowControl;
if (!tmp_ann_custom_FlowControl.empty())
{
ann_custom_FlowControl = tmp_ann_custom_FlowControl;
}

CompleteTypeDetail detail_FlowControl = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_FlowControl, ann_custom_FlowControl, type_name_FlowControl.to_string());
CompleteStructHeader header_FlowControl;
header_FlowControl = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_FlowControl);
Expand Down
12 changes: 9 additions & 3 deletions examples/cpp/flow_control/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ void PublisherApp::run()
}
else
{
throw std::runtime_error("Slow Publisher failed sending a message");
if (!is_stopped())
{
std::cout << "Slow Publisher failed sending a message" << std::endl;
}
}

if (publish(fast_writer_, msg))
Expand All @@ -200,7 +203,10 @@ void PublisherApp::run()
}
else
{
throw std::runtime_error("Fast Publisher failed sending a message");
if (!is_stopped())
{
std::cout << "Fast Publisher failed sending a message" << std::endl;
}
}

// Wait for period or stop event
Expand All @@ -214,7 +220,7 @@ void PublisherApp::run()

bool PublisherApp::publish(
DataWriter* writer_,
FlowControl msg)
FlowControl& msg)
{
bool ret = false;
// Wait for the data endpoints discovery
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/flow_control/PublisherApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PublisherApp : public Application, public DataWriterListener
//! Publish a sample
bool publish(
DataWriter* writer_,
FlowControl msg);
FlowControl& msg);

DomainParticipant* participant_;

Expand Down
1 change: 0 additions & 1 deletion examples/cpp/rtps/CLIParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ class CLIParser
if (static_cast<uint16_t>(input) > std::numeric_limits<std::uint16_t>::max())
{
throw std::out_of_range("sample argument out of range");
print_help(EXIT_FAILURE);
}

config.samples = static_cast<uint16_t>(input);
Expand Down

0 comments on commit 817b14a

Please sign in to comment.