Skip to content

add thread naming utilities#213

Merged
ahcorde merged 7 commits intoros2:rollingfrom
fireflyautomatix:2818-custom-thread-names
Jun 18, 2025
Merged

add thread naming utilities#213
ahcorde merged 7 commits intoros2:rollingfrom
fireflyautomatix:2818-custom-thread-names

Conversation

@Aposhian
Copy link
Copy Markdown
Contributor

Description

Moved thread naming utilities from ros2/rclcpp#2871.

Fixes ros2/rclcpp#2818

Is this user-facing behavior change?

No, just new interfaces.

Did you use Generative AI?

Yes. Cursor autocomplete.

Additional Information

Signed-off-by: Adam Aposhian <adam.aposhian@fireflyautomatix.com>

// This includes the null terminator
#if defined(__APPLE__)
constexpr size_t MAXTHREADNAMESIZE = 64;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include <cstddef>

Copy link
Copy Markdown
Contributor Author

@Aposhian Aposhian Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • add include for size_t

std::error_code error_code(result, std::system_category());
throw std::system_error(error_code, "Failed to get thread name");
}
std::wstringstream wss;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include <sstream>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is included, but only on windows.


std::string get_thread_name()
{
std::string name;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include <string>

Copy link
Copy Markdown
Contributor Author

@Aposhian Aposhian Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • add string include to cpp

Aposhian added 3 commits June 17, 2025 11:01
Signed-off-by: Adam Aposhian <adam.aposhian@fireflyautomatix.com>
Signed-off-by: Adam Aposhian <adam.aposhian@fireflyautomatix.com>
Signed-off-by: Adam Aposhian <adam.aposhian@fireflyautomatix.com>
@Aposhian Aposhian force-pushed the 2818-custom-thread-names branch from 230621f to 2a2a955 Compare June 17, 2025 17:03
Signed-off-by: Adam Aposhian <adam.aposhian@fireflyautomatix.com>
@Aposhian
Copy link
Copy Markdown
Contributor Author

I finally got my Windows development environment up, so I was able to test, and now this compiles and tests pass on Windows. I have still not tested on Apple

@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Jun 18, 2025

Pulls: #213, ros2/rclcpp#2871
Gist: https://gist.githubusercontent.com/ahcorde/55c4014e22192d458adca070dac5e92d/raw/879545f9eaba7f535360c0ac4bfb442f4f33868e/ros2.repos
BUILD args: --packages-up-to rclcpp_components rcpputils --packages-above-and-dependencies rclcpp_components rcpputils
TEST args: --packages-select rclcpp_components rcpputils --packages-above rclcpp_components rcpputils
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/16245

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Copy link
Copy Markdown
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows is failing

test_thread_name.obj : error LNK2019: unresolved external symbol "void __cdecl rcpputils::set_thread_name(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?set_thread_name@rcpputils@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: virtual void __cdecl TestOsThread_set_thread_name_Test::TestBody(void)" (?TestBody@TestOsThread_set_thread_name_Test@@EEAAXXZ) [C:\ci\ws\build\rcpputils\test_thread_name.vcxproj]

test_thread_name.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl rcpputils::get_thread_name(void)" (?get_thread_name@rcpputils@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "private: virtual void __cdecl TestOsThread_set_thread_name_Test::TestBody(void)" (?TestBody@TestOsThread_set_thread_name_Test@@EEAAXXZ) [C:\ci\ws\build\rcpputils\test_thread_name.vcxproj]

uncrustify is also failing

Aposhian added 2 commits June 18, 2025 06:59
Signed-off-by: Adam Aposhian <adam.aposhian@fireflyautomatix.com>
Signed-off-by: Adam Aposhian <adam.aposhian@fireflyautomatix.com>
@Aposhian
Copy link
Copy Markdown
Contributor Author

Ok I believe the windows build should be fixed now. My Windows build environment is a bit of a mess, so I wasn't replicating the build settings that ament and colcon use correctly.

@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Jun 18, 2025

Pulls: ros2/rclcpp#2871, #213
Gist: https://gist.githubusercontent.com/ahcorde/883710a7fcaac7eb9684fc51a451c8c6/raw/06341f2c44e076f6ce82aad3d2da3d6fdfb3e9b1/ros2.repos
BUILD args: --packages-up-to rclcpp rcpputils --packages-above-and-dependencies rclcpp rcpputils
TEST args: --packages-select rclcpp rcpputils --packages-above rclcpp rcpputils
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/16259

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde ahcorde merged commit 8e29c4c into ros2:rolling Jun 18, 2025
3 checks passed
@Aposhian Aposhian deleted the 2818-custom-thread-names branch June 18, 2025 21:08
Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aposhian sorry for being late to get back to you since i was on vacation last week. and thanks for moving the function to rcpputils. already merged, lgtm anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding custom thread names to component_container_isolated

3 participants