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

std::in_place_stop_source::get_token and std::get_stop_token const correctness #46

Open
jtsylve opened this issue Aug 17, 2023 · 1 comment
Labels
question Further information is requested

Comments

@jtsylve
Copy link

jtsylve commented Aug 17, 2023

In the current proposal, in_place_stop_source::get_token is const qualified, and std::get_stop_token requires a const parameter.

The problem in practice is that token callbacks almost certainly need to register themselves with the source, which tends to require that the token maintain a pointer or reference to the source. With get_token being const qualified, the source can only pass a constant reference or pointer to itself to be stored by the token, but the callback almost certainly needs to mutate the source to register itself.

libunifex doesn't have this issue because their implementation of get_token is not const qualified.
stdexec follows the specification and had to resort to marking its list of callbacks as mutable, which is usually considered a code smell by many.

I am curious about the reasoning behind this decision. I know that std::stop_source made the same choice, but those implementations do not require callback registration.

@ericniebler ericniebler added the question Further information is requested label Dec 7, 2023
@ericniebler
Copy link
Collaborator

This is a good question for @lewissbaker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants