Skip to content

Commit 04bd1cc

Browse files
committed
Make set_current_thread_name public
1 parent c5cfa8a commit 04bd1cc

4 files changed

Lines changed: 12 additions & 16 deletions

File tree

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// Official repository: https://github.com/cppalliance/capy
88
//
99

10-
#ifndef BOOST_CAPY_DETAIL_THREAD_NAME_HPP
11-
#define BOOST_CAPY_DETAIL_THREAD_NAME_HPP
10+
#ifndef BOOST_CAPY_THREAD_NAME_HPP
11+
#define BOOST_CAPY_THREAD_NAME_HPP
1212

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

@@ -27,7 +27,6 @@
2727

2828
namespace boost {
2929
namespace capy {
30-
namespace detail {
3130

3231
/** Set the name of the current thread for debugging purposes.
3332
@@ -42,7 +41,6 @@ BOOST_CAPY_DECL
4241
void
4342
set_current_thread_name(char const* name) noexcept;
4443

45-
} // detail
4644
} // capy
4745
} // boost
4846

src/ex/thread_pool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <boost/capy/ex/thread_pool.hpp>
1212
#include <boost/capy/detail/intrusive.hpp>
13-
#include <boost/capy/detail/thread_name.hpp>
13+
#include <boost/capy/thread_name.hpp>
1414
#include <condition_variable>
1515
#include <cstdio>
1616
#include <mutex>
@@ -134,7 +134,7 @@ class thread_pool::impl
134134
// Build name; set_current_thread_name truncates to platform limits.
135135
char name[16];
136136
std::snprintf(name, sizeof(name), "%s%zu", thread_name_prefix_, index);
137-
detail::set_current_thread_name(name);
137+
set_current_thread_name(name);
138138

139139
for(;;)
140140
{
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Official repository: https://github.com/cppalliance/capy
88
//
99

10-
#include <boost/capy/detail/thread_name.hpp>
10+
#include <boost/capy/thread_name.hpp>
1111

1212
#if defined(_WIN32)
1313

@@ -45,7 +45,6 @@
4545

4646
namespace boost {
4747
namespace capy {
48-
namespace detail {
4948

5049
void
5150
set_current_thread_name(char const* name) noexcept
@@ -97,6 +96,5 @@ set_current_thread_name(char const* name) noexcept
9796
#endif
9897
}
9998

100-
} // detail
10199
} // capy
102100
} // boost

test/unit/thread_name.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//
99

1010
// Test that header file is self-contained.
11-
#include <boost/capy/detail/thread_name.hpp>
11+
#include <boost/capy/thread_name.hpp>
1212

1313
#include "test_helpers.hpp"
1414

@@ -21,14 +21,14 @@ struct thread_name_test
2121
testSetName()
2222
{
2323
#if defined(BOOST_CAPY_TEST_CAN_GET_THREAD_NAME)
24-
detail::set_current_thread_name("test-thread");
24+
set_current_thread_name("test-thread");
2525
BOOST_TEST(check_thread_name("test-thread"));
2626

27-
detail::set_current_thread_name("capy-pool-0");
27+
set_current_thread_name("capy-pool-0");
2828
BOOST_TEST(check_thread_name("capy-pool-0"));
2929

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

4545
// Test macOS 63-char limit specifically
46-
detail::set_current_thread_name(
46+
set_current_thread_name(
4747
"0123456789012345678901234567890123456789012345678901234567890123456789");
4848
#if defined(__APPLE__)
4949
// Truncated to 63 chars
@@ -53,14 +53,14 @@ struct thread_name_test
5353

5454
#if defined(_WIN32)
5555
// Windows UTF-8 support (simple ASCII subset)
56-
detail::set_current_thread_name("worker-thread-1");
56+
set_current_thread_name("worker-thread-1");
5757
BOOST_TEST(check_thread_name("worker-thread-1"));
5858
#endif
5959
#endif // BOOST_CAPY_TEST_CAN_GET_THREAD_NAME
6060

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

6666
void

0 commit comments

Comments
 (0)