yahoo / yahoo/proxy-verifier

Convert std::thread to std::jthread with cooperative cancellation

Open
#237 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.