Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bneradt opened this issue Dec 22, 2022 · 0 comments
Open

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

bneradt opened this issue Dec 22, 2022 · 0 comments

Comments

@bneradt
Copy link
Collaborator

bneradt commented Dec 22, 2022

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
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

No branches or pull requests

1 participant