Reputation: 13689
The question says it. [thread.jthread.stop]/1 says:
[[nodiscard]] stop_source get_stop_source() noexcept;
Effects: Equivalent to:
return ssource
;
Why is it not a pure observer?
Upvotes: 0
Views: 136
Reputation: 473946
A stop_source
object allows you to request that the thread which has such an object (or its attendant stop_token
) perform a stop. Such a request is not logically const
. As such, if you fetch a stop_source
for a jthread
, it is expected that you are going to perform the aforementioned "not logically const
" operation.
So the function you used to retrieve it is not const
. Note that getting a stop_token
is const
, as this is an observer of thread-safe state, not a modifier of it.
Upvotes: 2