std::jthread::get_stop_source - cppreference.com (original) (raw)

Returns a std::stop_source associated with the same shared stop-state as held internally by the jthread object.

[edit] Parameters

(none)

[edit] Return value

A value of type std::stop_source associated with stop-state held internally by jthread object.

[edit] Example

Possible output:

stop_source: stop_possible = true, stop_requested = false   Pass source to other thread: Sleepy worker goes back to sleep Request stop for worker via source Sleepy worker is requested to stop   stop_source: stop_possible = true, stop_requested = true