BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsl::stop_callback< t_CALLBACK > Class Template Reference

#include <bslstl_stoptoken.h>

Public Types

typedef t_CALLBACK callback_type
 
typedef BloombergLP::bslstl::StopCallback_Node< t_CALLBACK >::allocator_type allocator_type
 

Public Member Functions

template<class t_ARG >
 stop_callback (const stop_token &token, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG) arg, const allocator_type &alloc=allocator_type())
 
template<class t_ARG >
 stop_callback (BloombergLP::bslmf::MovableRef< stop_token > token, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG) arg, const allocator_type &alloc=allocator_type())
 
template<class t_ARG >
 stop_callback (const stop_token &token, t_ARG &arg, const allocator_type &alloc=allocator_type())
 
template<class t_ARG >
 stop_callback (BloombergLP::bslmf::MovableRef< stop_token > token, t_ARG &arg, const allocator_type &alloc=allocator_type())
 
 ~stop_callback ()
 
allocator_type get_allocator () const
 

Detailed Description

template<class t_CALLBACK>
class bsl::stop_callback< t_CALLBACK >

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.

See bslstl_stoptoken

Member Typedef Documentation

◆ allocator_type

template<class t_CALLBACK >
typedef BloombergLP::bslstl::StopCallback_Node<t_CALLBACK>::allocator_type bsl::stop_callback< t_CALLBACK >::allocator_type

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

◆ callback_type

template<class t_CALLBACK >
typedef t_CALLBACK bsl::stop_callback< t_CALLBACK >::callback_type

Constructor & Destructor Documentation

◆ stop_callback() [1/4]

template<class t_CALLBACK >
template<class t_ARG >
bsl::stop_callback< t_CALLBACK >::stop_callback ( const stop_token token,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG)  arg,
const allocator_type alloc = allocator_type() 
)
explicit

Create a stop_callback object whose stored callable is constructed by forwarding from the specified arg; if t_CALLBACK is allocator-aware, the optionally specified alloc will be used to supply memory instead of the default allocator (otherwise, alloc is ignored). If the specified token refers to a stop state on which a stop has been requested, invoke the callback before returning; otherwise, if token refers to a stop state, associate *this with that stop state and register the callback with that stop state. Unlike the constructors of std::stop_callback, these constructors do not currently have a noexcept specification. Note that if token is an rvalue reference, it is unspecified whether this function moves from token.

◆ stop_callback() [2/4]

template<class t_CALLBACK >
template<class t_ARG >
bsl::stop_callback< t_CALLBACK >::stop_callback ( BloombergLP::bslmf::MovableRef< stop_token token,
BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG)  arg,
const allocator_type alloc = allocator_type() 
)
explicit

◆ stop_callback() [3/4]

template<class t_CALLBACK >
template<class t_ARG >
bsl::stop_callback< t_CALLBACK >::stop_callback ( const stop_token token,
t_ARG &  arg,
const allocator_type alloc = allocator_type() 
)
explicit

◆ stop_callback() [4/4]

template<class t_CALLBACK >
template<class t_ARG >
bsl::stop_callback< t_CALLBACK >::stop_callback ( BloombergLP::bslmf::MovableRef< stop_token token,
t_ARG &  arg,
const allocator_type alloc = allocator_type() 
)
explicit

◆ ~stop_callback()

template<class t_CALLBACK >
bsl::stop_callback< t_CALLBACK >::~stop_callback ( )

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.

Member Function Documentation

◆ get_allocator()

template<class t_CALLBACK >
stop_callback< t_CALLBACK >::allocator_type bsl::stop_callback< t_CALLBACK >::get_allocator ( ) const

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.


The documentation for this class was generated from the following file: