Home - DryPerspective/Cpp17_jthread GitHub Wiki

C++17 jthread

A recreation of the std::jthread concurrency tools for C++17. Includes the traditional stop_source and token, jthread itself, stop callbacks, and a condition variable. This repo requires the C++17 standard to compile. It will continue to function in later standards, but it is recommended to migrate to the standard tools should C++20 or higher become available for your project.

The interface of the tools in this repo should match their standard counterparts exactly. However, for the sake of full documentation, a complete writeup of each tool can be found on this wiki. The tools included in this repo are:

dp::stop_sourcedp::stop_tokendp::stop_callback Analogues of std::stop_source, std::stop_token, and std::stop_callback to manage stop requests safely and register callbacks to be executed when a stop is requested.
dp::nostopstate_tdp::nostopstate A tag type used to construct a dp::stop_source with no associated stop state.
dp::jthread A recreation of std::jthread, a thread object which will request a stop and attempt to join on destruction, and which can be constructed with a callable which uses the thread's own stop token to monitor stop requests.
dp::condition_variable_any An implementation of std::condition_variable_any with the ability to be notified when a stop is requested from an associated stop_source.
dp::condition_variabledp::cv_statusdp::notify_all_at_thread_exit Aliases for their std:: counterparts, which exist for consistency when using namespace dp constructs.