refactor(sonar): migrate worker threads to std::jthread (#5398)

This commit is contained in:
Dave Lane
2026-07-12 00:30:05 -04:00
committed by GitHub
parent 40ae6c8002
commit 3377f7a73f
24 changed files with 79 additions and 48 deletions

View File

@@ -42,7 +42,7 @@ INSTANTIATE_TEST_SUITE_P(
);
TEST_P(AudioTest, TestEncode) {
std::thread timer([&] {
std::jthread timer([&] {
// Terminate the audio capture after 100 ms
std::this_thread::sleep_for(100ms);
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
@@ -50,7 +50,7 @@ TEST_P(AudioTest, TestEncode) {
shutdown_event->raise(true);
audio_packets->stop();
});
std::thread capture([&] {
std::jthread capture([&] {
const auto packets = m_mail->queue<packet_t>(mail::audio_packets);
const auto shutdown_event = m_mail->event<bool>(mail::shutdown);
while (const auto packet = packets->pop()) {

View File

@@ -93,7 +93,7 @@ class ConfigHttpTest: public BaseTest { // NOSONAR(cpp:S3656) - protected membe
protected:
std::unique_ptr<SimpleWeb::Server<SimpleWeb::HTTPS>> server;
std::unique_ptr<SimpleWeb::Client<SimpleWeb::HTTPS>> client;
std::thread server_thread; // NOSONAR(cpp:S6168) - jthread not available on FreeBSD 14.3 libc++
std::jthread server_thread;
unsigned short port = 0;
std::string saved_username;
@@ -310,7 +310,7 @@ protected:
};
// Start server
server_thread = std::thread([this]() { // NOSONAR(cpp:S6168) - jthread not available on FreeBSD 14.3 libc++
server_thread = std::jthread([this]() {
server->start([this](const unsigned short assigned_port) {
port = assigned_port;
});