futures/stop_token.hpp
Stop tokens.
#include <futures/stop_token.hpp>
Namespaces
Name | Description |
---|---|
futures | Main library namespace. |
Classes
Classes | Description |
---|---|
nostopstate_t | Empty struct to initialize a stop_source without a shared stop state. (struct) |
stop_token | Token to check if a stop request has been made. (class) |
stop_source | Object used to issue a stop request. (class) |
Description
This header contains is an adapted version of std::stop_token for futures rather than threads.
The main difference in this implementation is 1) the reference counter does not distinguish between tokens and sources, and 2) there is no stop_callback.
The API was initially adapted from Baker Josuttis' reference implementation for C++20:
Although the std::future
class is obviously different from std::jthread
, this stop_token
is not different from std::stop_token. The main goal here is just to provide a stop source in C++17. In the future, we might replace this with an alias to a C++20 std::stop_token.
See Also: https://github.com/josuttis/jthread
Updated on 2023-01-04