Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// Official repository: https://github.com/cppalliance/capy
//

#ifndef BOOST_CAPY_DETAIL_THREAD_NAME_HPP
#define BOOST_CAPY_DETAIL_THREAD_NAME_HPP
#ifndef BOOST_CAPY_TEST_THREAD_NAME_HPP
#define BOOST_CAPY_TEST_THREAD_NAME_HPP

#include <boost/capy/detail/config.hpp>

Expand All @@ -27,7 +27,6 @@

namespace boost {
namespace capy {
namespace detail {

/** Set the name of the current thread for debugging purposes.

Expand All @@ -42,7 +41,6 @@ BOOST_CAPY_DECL
void
set_current_thread_name(char const* name) noexcept;

} // detail
} // capy
} // boost

Expand Down
4 changes: 2 additions & 2 deletions src/ex/thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <boost/capy/ex/thread_pool.hpp>
#include <boost/capy/detail/intrusive.hpp>
#include <boost/capy/detail/thread_name.hpp>
#include <boost/capy/test/thread_name.hpp>
#include <condition_variable>
#include <cstdio>
#include <mutex>
Expand Down Expand Up @@ -134,7 +134,7 @@ class thread_pool::impl
// Build name; set_current_thread_name truncates to platform limits.
char name[16];
std::snprintf(name, sizeof(name), "%s%zu", thread_name_prefix_, index);
detail::set_current_thread_name(name);
set_current_thread_name(name);

for(;;)
{
Expand Down
4 changes: 1 addition & 3 deletions src/detail/thread_name.cpp → src/test/thread_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Official repository: https://github.com/cppalliance/capy
//

#include <boost/capy/detail/thread_name.hpp>
#include <boost/capy/test/thread_name.hpp>

#if defined(_WIN32)

Expand Down Expand Up @@ -45,7 +45,6 @@

namespace boost {
namespace capy {
namespace detail {

void
set_current_thread_name(char const* name) noexcept
Expand Down Expand Up @@ -97,6 +96,5 @@ set_current_thread_name(char const* name) noexcept
#endif
}

} // detail
} // capy
} // boost
14 changes: 7 additions & 7 deletions test/unit/thread_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//

// Test that header file is self-contained.
#include <boost/capy/detail/thread_name.hpp>
#include <boost/capy/test/thread_name.hpp>

#include "test_helpers.hpp"

Expand All @@ -21,14 +21,14 @@ struct thread_name_test
testSetName()
{
#if defined(BOOST_CAPY_TEST_CAN_GET_THREAD_NAME)
detail::set_current_thread_name("test-thread");
set_current_thread_name("test-thread");
BOOST_TEST(check_thread_name("test-thread"));

detail::set_current_thread_name("capy-pool-0");
set_current_thread_name("capy-pool-0");
BOOST_TEST(check_thread_name("capy-pool-0"));

// Long name is truncated to 15 chars on Linux/FreeBSD/NetBSD
detail::set_current_thread_name(
set_current_thread_name(
"this-is-a-very-long-thread-name-that-exceeds-limits");
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
BOOST_TEST(check_thread_name("this-is-a-very-"));
Expand All @@ -43,7 +43,7 @@ struct thread_name_test
#endif

// Test macOS 63-char limit specifically
detail::set_current_thread_name(
set_current_thread_name(
"0123456789012345678901234567890123456789012345678901234567890123456789");
#if defined(__APPLE__)
// Truncated to 63 chars
Expand All @@ -53,14 +53,14 @@ struct thread_name_test

#if defined(_WIN32)
// Windows UTF-8 support (simple ASCII subset)
detail::set_current_thread_name("worker-thread-1");
set_current_thread_name("worker-thread-1");
BOOST_TEST(check_thread_name("worker-thread-1"));
#endif
#endif // BOOST_CAPY_TEST_CAN_GET_THREAD_NAME

// Empty string should not crash (but we don't verify the result
// since some platforms may not support clearing thread names)
detail::set_current_thread_name("");
set_current_thread_name("");
}

void
Expand Down
Loading