This class holds an object or reference of type t_CALLBACK and, when constructed using a stop_token that owns a stop state, schedules the held object or reference to be executed by the thread that requests cancellation on that stop state (if any). However, if cancellation was already requested before the stop_callback was constructed, the constructor invokes the callback immediately. If there is no stop state, or request_stop is never called for the stop state, then the callback is not invoked. stop_callback stores its callback within its own footprint, and thus never requires memory allocation; however, stop_callback<t_CALLBACK> is an allocator‐aware class, if t_CALLBACK is an allocator‐aware class, and any supplied allocator will then be passed to the constructor of t_CALLBACK.

Synopsis

Declared in <bslstl_stoptoken.h>

template<class t_CALLBACK>
class stop_callback;

Type Aliases

Name

Description

allocator_type

The allocator type is bsl::allocator<char> if t_CALLBACK is allocator‐aware, and an empty dummy type otherwise.

callback_type

Alias for the callback callable type stored by this stop_callback.

Member Functions

Name

Description

stop_callback [constructor]

Constructors

~stop_callback [destructor]

Destroy this object. If *this refers to a stop state and the stored callback is registered with the stop state but has not yet begun execution, deregister the callback from that stop state. Otherwise, if the callback is executing on a thread other than the thread invoking the destructor, the completion of the callback strongly happens before the destructor returns.

get_allocator

If t_CALLBACK is allocator‐aware, return the allocator used to construct this object; otherwise, the return type is void and the definition of this function is ill‐formed.

Deduction Guides

Name

Description

stop_callback<t_CALLBACK>

Deduce t_CALLBACK from the type of the callable passed to stop_callback.

Created with MrDocs