Title
Stop token data race avoidance requirements unclear
Status
new
Section
[thread.stoptoken.intro]
Submitter
Brian Bi

Created on 2023-04-16.00:00:00 last changed 18 months ago

Messages

Date: 2023-05-24.14:33:00

Proposed resolution:

This wording is relative to N4944.

  1. Modify [thread.stoptoken.intro] as indicated:

    -5- Calls to the functions request_stop, stop_requested, and stop_possible do not introduce data races with each other. A call to request_stop that returns true synchronizes with a call to stop_requested on an associated stop_token or stop_source object that returns true. Registration of a callback synchronizes with the invocation of that callback.

Date: 2023-05-15.00:00:00

[ 2023-05-24; Reflector poll ]

Set priority to 3 after reflector poll.

"What about get_token? operator==?"

"Other functions like get_stop_token can also be called concurrently. I think the text is actually correct."

Date: 2023-04-16.00:00:00

The first sentence of [thread.stoptoken.intro]/5 says:

Calls to the functions request_stop, stop_requested, and stop_possible do not introduce data races.

This could be read as saying that if you have a program that doesn't contain data races, and you change it by adding a call to any of these three functions, such a change does not "introduce" data races into the program. In other words, it could be read as saying that these three functions don't race with any other member functions on the same stop_token or stop_source object.

I'm guessing the actual intended meaning is that calls to these three functions do not race with each other, because it would be more expensive if concurrent calls with stop_token::operator= were also required to not race. (Also, none of these functions can avoid racing with the destructor.)

History
Date User Action Args
2023-05-24 14:33:00adminsetmessages: + msg13574
2023-04-16 16:05:58adminsetmessages: + msg13528
2023-04-16 00:00:00admincreate