Convert std::thread to std::jthread with cooperative cancellation
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 47
- Forks
- 29
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 3
Description
Each accepted connection is currently handled by a std::thread. We can use C++20 now, which offers std::jthread. In addition to the resource management benefits, it also supports cooperative cancellation (stop_token) which should improve the way interruption of connections is handled (i.e., Ctrl-C is passed and the threads need to go away swiftly).
In short, we should consider using:
- jthread
- std::stop_source/token with the jthreads.
- std::condition_variable_any with the std::stop_token
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the accepted-connection handling that currently creates std::thread and trace how Ctrl-C interruption reaches those threads. Review the existing build and test coverage, then verify that std::jthread, stop_source/token, and condition_variable_any provide prompt cooperative cancellation without breaking connection handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- networking
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100