Skip to content

Commit

Permalink
Updated the rcl interface in accordance with the specifications outli…
Browse files Browse the repository at this point in the history
  • Loading branch information
smorita-esol committed Aug 10, 2023
1 parent b0988dd commit 0e9616a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
12 changes: 4 additions & 8 deletions rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,15 @@ MultiThreadedExecutor::MultiThreadedExecutor(
thread_attributes_(nullptr)
{
bool has_number_of_threads_arg = number_of_threads > 0;
rcl_ret_t ret;

number_of_threads_ = number_of_threads > 0 ?
number_of_threads :
std::max(rcpputils::Thread::hardware_concurrency(), 2U);

ret = rcl_arguments_get_thread_attrs(
&options.context->get_rcl_context()->global_arguments,
&thread_attributes_);
if (ret != RCL_RET_OK) {
ret = rcl_context_get_thread_attrs(
options.context->get_rcl_context().get(),
&thread_attributes_);
if (rcutils_thread_attrs_t * attrs = rcl_context_get_thread_attrs(
options.context->get_rcl_context().get()))
{
thread_attributes_ = attrs;
}

if (has_number_of_threads_arg && thread_attributes_ &&
Expand Down
14 changes: 5 additions & 9 deletions rclcpp/src/rclcpp/executors/single_threaded_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ SingleThreadedExecutor::SingleThreadedExecutor(const rclcpp::ExecutorOptions & o
: rclcpp::Executor(options),
thread_attributes_(nullptr)
{
rcl_ret_t ret;

ret = rcl_arguments_get_thread_attrs(
&options.context->get_rcl_context()->global_arguments,
&thread_attributes_);
if (ret != RCL_RET_OK) {
ret = rcl_context_get_thread_attrs(
options.context->get_rcl_context().get(),
&thread_attributes_);
if (rcutils_thread_attrs_t * attrs = rcl_context_get_thread_attrs(
options.context->get_rcl_context().get()))
{
thread_attributes_ = attrs;
}

if (thread_attributes_ && thread_attributes_->num_attributes != 1) {
RCLCPP_WARN(
rclcpp::get_logger("rclcpp"),
Expand Down

0 comments on commit 0e9616a

Please sign in to comment.