vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

refactor(samples): replace pthreads with std::thread in multithreaded sample

Open Subham-KRLX opened this issue 7 months ago • 8 comments

This PR addresses issue #13732 by refactoring the multithreaded sample to use C++11 instead of pthreads.

✅ Highlights:

  • Replaced platform-specific pthread code with std::thread
  • Improved thread safety using atomic operations
  • Updated Makefile to reflect C++11 changes
  • Validated build on macOS and ensured cross-platform compatibility

Subham-KRLX avatar Jun 27 '25 05:06 Subham-KRLX

@sean-mcmanus All requested changes are now complete:

  • Removed all pthread dependencies
  • Deleted unnecessary config files
  • Verified thread safety and execution Ready for your final review.

Subham-KRLX avatar Jun 28 '25 01:06 Subham-KRLX

Hi @sean-mcmanus, All requested changes have been addressed:

Fully migrated from pthreads to std::thread Cleaned up unneeded config files Improved thread safety, verified cross-platform build Updated tasks.json and Makefile for C++11 All checks are passing, and the PR is ready for your final review.

Please let me know if anything else is needed!

Subham-KRLX avatar Jul 01 '25 16:07 Subham-KRLX

Reverted all changes to Extension/.vscode/tasks.json as requested. The PR now only includes the sample refactor. Ready for review!

Subham-KRLX avatar Jul 02 '25 02:07 Subham-KRLX

@sean-mcmanus confirmation:

  1. Extension/.vscode/tasks.json is now identical to main@76b0fac (verified via hash check)
  2. All pthread dependencies removed from Fib sample
  3. Zero unintended changes remain

This PR now contains:

  • std::thread migration in Fib sample
  • Removed VS/pthread-related files
  • Clean cross-platform builds

Subham-KRLX avatar Jul 03 '25 04:07 Subham-KRLX

@sean-mcmanus To clarify:

  1. Extension/.vscode/tasks.json remains unchanged (matches main@76b0fac)
  2. The modified Code Samples/Fib/.vscode/tasks.json is:
    • Specific to the Fib sample build
    • Properly updated for the std::thread migration
    • Contains only Fib-related build configurations

Subham-KRLX avatar Jul 03 '25 04:07 Subham-KRLX

Hi @sean-mcmanus, All the requested changes especially around Extension/.vscode/tasks.json and the full std::thread migration, are now pushed.

Subham-KRLX avatar Jul 17 '25 04:07 Subham-KRLX

@Subham-KRLX We've been busy -- we'll try to review this next week.

sean-mcmanus avatar Jul 26 '25 01:07 sean-mcmanus

@Colengms I have made all the changes you suggested Fixed the build.cmd issue and removed the Makefile since it wasn't needed. Switched those volatile variables to atomic and got rid of the srand call. Also cleaned up that empty thread naming function and simplified the whole test counting thing like you recommended.

Subham-KRLX avatar Sep 20 '25 11:09 Subham-KRLX