Skip to content

Commit 9ae35e3

Browse files
authored
Select executor in node registration (#1898)
* Select executor Signed-off-by: Hirokazu Ishida <[email protected]> * Fix indent Signed-off-by: Hirokazu Ishida <[email protected]>
1 parent 0f58bb8 commit 9ae35e3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

rclcpp_components/cmake/rclcpp_components_register_node.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# :type RESOURCE_INDEX: string
2929
#
3030
macro(rclcpp_components_register_node target)
31-
cmake_parse_arguments(ARGS "" "PLUGIN;EXECUTABLE;RESOURCE_INDEX" "" ${ARGN})
31+
cmake_parse_arguments(ARGS "" "PLUGIN;EXECUTABLE;EXECUTOR;RESOURCE_INDEX" "" ${ARGN})
3232
if(ARGS_UNPARSED_ARGUMENTS)
3333
message(FATAL_ERROR "rclcpp_components_register_node() called with unused "
3434
"arguments: ${ARGS_UNPARSED_ARGUMENTS}")
@@ -46,6 +46,13 @@ macro(rclcpp_components_register_node target)
4646
message(STATUS "Setting component resource index to non-default value ${resource_index}")
4747
endif()
4848

49+
# default to executor if not specified otherwise
50+
set(executor "SingleThreadedExecutor")
51+
if(NOT "${ARGS_EXECUTOR}" STREQUAL "")
52+
set(executor ${ARGS_EXECUTOR})
53+
message(STATUS "Setting executor non-default value ${executor}")
54+
endif()
55+
4956
set(component ${ARGS_PLUGIN})
5057
set(node ${ARGS_EXECUTABLE})
5158
_rclcpp_components_register_package_hook()

rclcpp_components/src/node_main.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main(int argc, char * argv[])
2727
{
2828
auto args = rclcpp::init_and_remove_ros_arguments(argc, argv);
2929
rclcpp::Logger logger = rclcpp::get_logger(NODE_MAIN_LOGGER_NAME);
30-
rclcpp::executors::SingleThreadedExecutor exec;
30+
rclcpp::executors::@executor@ exec;
3131
rclcpp::NodeOptions options;
3232
options.arguments(args);
3333
std::vector<class_loader::ClassLoader * > loaders;

0 commit comments

Comments
 (0)