Mechanism for requesting and observing cancellation on a stop state.

Synopsis

Declared in <bslstl_stoptoken.h>

class stop_source;

Description

This class is a mechanism for making and observing cancellation requests. An object of this class may have (possibly shared) ownership of a stop state, in which case it can be used to make a cancellation request or observe whether a cancellation request has been made on the owned stop state; it is also possible for a stop_source object to not own a stop state. Due to its shared ownership semantics, it is safe to pass a copy of a stop_source object to a callback that might outlive the original stop_source object; however, a callback that should only be able to observe a cancellation request, without being able to request cancellation itself, should instead be passed a stop_token, which can be created by calling stop_source::get_token.

Member Functions

Name

Description

stop_source [constructor]

Constructors

~stop_source [destructor]

Destroy this object.

operator=

Assignment operators

get_token

Return a stop_token that refers to the stop state (or lack thereof) that *this refers to.

request_stop

Request a stop on the referred stop state, if any and not yet stopped.

stop_possible

Return whether this source currently refers to a stop state.

stop_requested

Return whether a stop has been requested on the referred stop state.

swap

Exchange the stop states referred to by *this and other.

Friends

Name

Description

bsl::swap

Exchange the stop states referred to by lhs and rhs.

bsl::operator==

Return whether lhs and rhs refer to the same stop state.

Created with MrDocs