Skip to content

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

Draft
ReenigneArcher wants to merge 2 commits into
masterfrom
refactor/use-jthread
Draft

refactor(sonar): migrate worker threads to std::jthread#5398
ReenigneArcher wants to merge 2 commits into
masterfrom
refactor/use-jthread

Conversation

@ReenigneArcher

Copy link
Copy Markdown
Member

Description

Replaced std::thread with std::jthread across runtime services, platform publish/audio paths, streaming/video pipelines, and related unit tests. This modernizes thread lifetime management by using auto-joining threads, reducing manual join/detach risks and simplifying shutdown behavior.

Screenshot

Issues Fixed or Closed

Fixes sonar cpp:S6168

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@ReenigneArcher ReenigneArcher added this to the sonar milestone Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 9.09091% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.73%. Comparing base (40ae6c8) to head (4c297e2).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/stream.cpp 0.00% 6 Missing ⚠️
src/video.cpp 0.00% 2 Missing and 1 partial ⚠️
src/nvhttp.cpp 0.00% 2 Missing ⚠️
src/platform/linux/publish.cpp 0.00% 2 Missing ⚠️
src/thread_pool.h 0.00% 2 Missing ⚠️
src/confighttp.cpp 0.00% 1 Missing ⚠️
src/platform/macos/publish.cpp 0.00% 1 Missing ⚠️
src/rtsp.cpp 0.00% 1 Missing ⚠️
src/system_tray.cpp 0.00% 1 Missing ⚠️
src/upnp.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5398      +/-   ##
==========================================
- Coverage   27.15%   25.73%   -1.42%     
==========================================
  Files         111      110       -1     
  Lines       25447    24166    -1281     
  Branches    11232    10528     -704     
==========================================
- Hits         6910     6220     -690     
+ Misses      17581    17171     -410     
+ Partials      956      775     -181     
Flag Coverage Δ
Archlinux ?
FreeBSD-aarch64 ?
FreeBSD-amd64 ?
Homebrew-macos-14 ?
Homebrew-macos-15 20.53% <5.26%> (ø)
Homebrew-macos-26 20.64% <5.26%> (-0.01%) ⬇️
Homebrew-ubuntu-24.04 12.94% <5.26%> (+0.01%) ⬆️
Linux-AppImage 12.27% <0.00%> (ø)
Windows-AMD64 ?
Windows-ARM64 13.24% <0.00%> (ø)
macOS-arm64 ?
macOS-x86_64 18.37% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/audio.cpp 84.04% <100.00%> (-1.75%) ⬇️
src/platform/linux/audio.cpp 62.30% <100.00%> (+2.15%) ⬆️
src/confighttp.cpp 41.71% <0.00%> (-2.05%) ⬇️
src/platform/macos/publish.cpp 20.00% <0.00%> (-10.19%) ⬇️
src/rtsp.cpp 23.26% <0.00%> (-0.86%) ⬇️
src/system_tray.cpp 12.72% <0.00%> (-4.59%) ⬇️
src/upnp.cpp 27.48% <0.00%> (-3.15%) ⬇️
src/nvhttp.cpp 33.46% <0.00%> (-0.99%) ⬇️
src/platform/linux/publish.cpp 0.00% <0.00%> (ø)
src/thread_pool.h 25.00% <0.00%> (ø)
... and 2 more

... and 65 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40ae6c8...4c297e2. Read the comment docs.

Replaced std::thread with std::jthread across runtime services, platform publish/audio paths, streaming/video pipelines, and related unit tests. This modernizes thread lifetime management by using auto-joining threads, reducing manual join/detach risks and simplifying shutdown behavior.
Remove compiler version check for the experimental library flag on Apple and FreeBSD, ensuring it's consistently applied. Add missing SUNSHINE_LINK_OPTIONS to both the main sunshine target and test target for consistent linker configuration.
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant