[#bsl-stop_source]
= xref:bsl.adoc[bsl]::stop&lowbar;source
:relfileprefix: ../
:mrdocs:

Mechanism for requesting and observing cancellation on a stop state&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;stoptoken&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class stop&lowbar;source;
----

== Description

This class is a mechanism for making and observing cancellation requests&period; 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&semi; it is also possible for a `stop&lowbar;source` object to not own a stop state&period; Due to its shared ownership semantics, it is safe to pass a copy of a `stop&lowbar;source` object to a callback that might outlive the original `stop&lowbar;source` object&semi; 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&lowbar;token`, which can be created by calling `stop&lowbar;source&colon;&colon;get&lowbar;token`&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/stop_source/2constructor-053.adoc[`stop&lowbar;source`]         [.small]#[constructor]#
| Constructors
| xref:bsl/stop_source/2destructor.adoc[`&#126;stop&lowbar;source`] [.small]#[destructor]#
| Destroy this object&period;
| xref:bsl/stop_source/operator_assign-00.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/stop_source/get_token.adoc[`get&lowbar;token`] 
| Return a `stop&lowbar;token` that refers to the stop state (or lack thereof) that `&ast;this` refers to&period;
| xref:bsl/stop_source/request_stop.adoc[`request&lowbar;stop`] 
| Request a stop on the referred stop state, if any and not yet stopped&period;
| xref:bsl/stop_source/stop_possible.adoc[`stop&lowbar;possible`] 
| Return whether this source currently refers to a stop state&period;
| xref:bsl/stop_source/stop_requested.adoc[`stop&lowbar;requested`] 
| Return whether a stop has been requested on the referred stop state&period;
| xref:bsl/stop_source/swap.adoc[`swap`] 
| Exchange the stop states referred to by `&ast;this` and `other`&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/swap-03fc.adoc[bsl::swap]`
| Exchange the stop states referred to by `lhs` and `rhs`&period;
| `xref:bsl/operator_eq-067.adoc[bsl::operator&equals;&equals;]`
| Return whether `lhs` and `rhs` refer to the same stop state&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
