8#ifndef INCLUDED_BSLSTL_STOPTOKEN
9#define INCLUDED_BSLSTL_STOPTOKEN
180#include <bsla_nodiscard.h>
204template <
class t_CALLBACK>
class stop_callback;
222 template <
class t_CALLBACK>
263template <
class t_CALLBACK,
283 BloombergLP::bslma::UsesBslmaAllocator<t_CALLBACK>::value,
293 template <
class t_ARG>
297 template <
class t_ARG>
317template <
class t_CALLBACK>
322 t_CALLBACK d_callback;
334 template <
class t_ARG>
337 template <
class t_ARG>
355template <
class t_CALLBACK>
372 template <
class t_ALLOC,
class t_ARG>
375 template <
class t_ALLOC,
class t_ARG>
417#if defined(BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES)
438#ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
439 template <
class t_CALLBACK>
445 typedef BloombergLP::bslstl::StopToken_RefCountedState RefCountedState;
446 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
456 template <
class t_CALLBACK>
467 return lhs.d_state_p ==
rhs.d_state_p;
470#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
478 return lhs.d_state_p !=
rhs.d_state_p;
488 lhs.d_state_p.swap(
rhs.d_state_p);
574 typedef BloombergLP::bslstl::StopToken_RefCountedState RefCountedState;
575 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
592 return lhs.d_state_p ==
rhs.d_state_p;
595#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
603 return lhs.d_state_p !=
rhs.d_state_p;
613 lhs.d_state_p.swap(
rhs.d_state_p);
634 stop_source(BloombergLP::bslmf::MovableRef<stop_source> original)
711template <class t_CALLBACK>
716 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
723 BloombergLP::bslstl::StopCallback_Node<t_CALLBACK> d_node;
746 typedef typename BloombergLP::bslstl::StopCallback_Node<
764 template <
class t_ARG>
769 template <
class t_ARG>
771 BloombergLP::bslmf::MovableRef<stop_token> token,
774 template <
class t_ARG>
779 template <
class t_ARG>
781 BloombergLP::bslmf::MovableRef<stop_token> token,
801#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
803template <
class t_CALLBACK>
810template <
class t_CALLBACK>
828inline StopCallback_NoAlloc::StopCallback_NoAlloc()
837template <
class t_CALLBACK,
bool t_IS_REFERENCE>
839StopCallback_CallbackStorage<t_CALLBACK, t_IS_REFERENCE>::mechanism(
845template <
class t_CALLBACK,
bool t_IS_REFERENCE>
846void *StopCallback_CallbackStorage<t_CALLBACK, t_IS_REFERENCE>::mechanism(
847 const StopCallback_NoAlloc&)
852template <
class t_CALLBACK,
bool t_IS_REFERENCE>
853template <
class t_ARG>
859 BloombergLP::bslma::ConstructionUtil::construct(
861 mechanism(allocator),
865template <
class t_CALLBACK,
bool t_IS_REFERENCE>
866template <
class t_ARG>
870 BloombergLP::bslma::ConstructionUtil::construct(d_buf.
address(),
871 mechanism(allocator),
875template <
class t_CALLBACK,
bool t_IS_REFERENCE>
877 t_IS_REFERENCE>::~StopCallback_CallbackStorage()
879 BloombergLP::bslma::DestructionUtil::destroy(d_buf.
address());
882template <
class t_CALLBACK,
bool t_IS_REFERENCE>
889template <
class t_CALLBACK,
bool t_IS_REFERENCE>
900template <
class t_CALLBACK>
901template <
class t_ARG>
909template <
class t_CALLBACK>
910template <
class t_ARG>
918template <
class t_CALLBACK>
929template <
class t_CALLBACK>
934#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
935 std::forward<t_CALLBACK>(
942template <
class t_CALLBACK>
943template <
class t_ALLOC,
class t_ARG>
945 const t_ALLOC& allocator,
953template <
class t_CALLBACK>
954template <
class t_ALLOC,
class t_ARG>
971: d_state_p(MoveUtil::move(state))
984: d_state_p(original.d_state_p)
989stop_token::stop_token(BloombergLP::bslmf::MovableRef<stop_token> original)
991: d_state_p(MoveUtil::move(MoveUtil::access(original).d_state_p))
996stop_token::~stop_token()
1005 d_state_p = other.d_state_p;
1013 d_state_p = MoveUtil::move(MoveUtil::access(other).d_state_p);
1020 d_state_p.
swap(other.d_state_p);
1035stop_source::stop_source(BloombergLP::bslmf::MovableRef<stop_source> original)
1037: d_state_p(MoveUtil::move(MoveUtil::access(original).d_state_p))
1045 d_state_p.
swap(other.d_state_p);
1053template <
class t_CALLBACK>
1056 if (d_state_p && !d_state_p->enregister(&d_node)) {
1062template <
class t_CALLBACK>
1063template <
class t_ARG>
1069, d_state_p(token.d_state_p)
1074template <
class t_CALLBACK>
1075template <
class t_ARG>
1077 BloombergLP::bslmf::MovableRef<stop_token> token,
1081, d_state_p(MoveUtil::move(MoveUtil::access(token).d_state_p))
1086template <
class t_CALLBACK>
1087template <
class t_ARG>
1092, d_state_p(token.d_state_p)
1097template <
class t_CALLBACK>
1098template <
class t_ARG>
1100 BloombergLP::bslmf::MovableRef<stop_token> token,
1104, d_state_p(MoveUtil::move(MoveUtil::access(token).d_state_p))
1109template <
class t_CALLBACK>
1113 d_state_p->deregister(&d_node);
1117template <
class t_CALLBACK>
1121 return d_node.callback().get_allocator();
Definition bslma_bslallocator.h:588
BloombergLP::bslma::Allocator * mechanism() const
Definition bslma_bslallocator.h:1146
Definition bslstl_sharedptr.h:1838
void swap(shared_ptr &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5516
void reset() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5449
Definition bslstl_stoptoken.h:712
t_CALLBACK callback_type
Definition bslstl_stoptoken.h:742
~stop_callback()
Definition bslstl_stoptoken.h:1110
BloombergLP::bslstl::StopCallback_Node< t_CALLBACK >::allocator_type allocator_type
Definition bslstl_stoptoken.h:747
allocator_type get_allocator() const
Definition bslstl_stoptoken.h:1119
Definition bslstl_stoptoken.h:570
friend void swap(stop_source &lhs, stop_source &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:611
~stop_source()
Destroy this object.
BSLA_NODISCARD friend bool operator!=(const stop_source &lhs, const stop_source &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:599
stop_source & operator=(BloombergLP::bslmf::MovableRef< stop_source > other) BSLS_KEYWORD_NOEXCEPT
stop_source(bsl::allocator< char > allocator)
stop_source(const stop_source &original) BSLS_KEYWORD_NOEXCEPT
bool request_stop() BSLS_KEYWORD_NOEXCEPT
stop_source & operator=(const stop_source &other) BSLS_KEYWORD_NOEXCEPT
BSLA_NODISCARD friend bool operator==(const stop_source &lhs, const stop_source &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:588
Definition bslstl_stoptoken.h:434
BSLA_NODISCARD friend bool operator==(const stop_token &lhs, const stop_token &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:463
BSLA_NODISCARD friend bool operator!=(const stop_token &lhs, const stop_token &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:474
friend class stop_source
Definition bslstl_stoptoken.h:454
friend class stop_callback
Definition bslstl_stoptoken.h:457
stop_token & operator=(const stop_token &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:1002
friend void swap(stop_token &lhs, stop_token &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:486
stop_token() BSLS_KEYWORD_NOEXCEPT
Create a stop_token object that does not refer to a stop state.
Definition bslstl_stoptoken.h:977
BSLA_NODISCARD bool stop_possible() const BSLS_KEYWORD_NOEXCEPT
BSLA_NODISCARD bool stop_requested() const BSLS_KEYWORD_NOEXCEPT
Definition bslma_allocator.h:545
Definition bsls_atomic.h:1205
StopCallback_NoAlloc allocator_type
Definition bslstl_stoptoken.h:326
Definition bslstl_stoptoken.h:265
~StopCallback_CallbackStorage()
Destroy this object.
Definition bslstl_stoptoken.h:877
bsl::conditional< BloombergLP::bslma::UsesBslmaAllocator< t_CALLBACK >::value, bsl::allocator< char >, StopCallback_NoAlloc >::type allocator_type
Definition bslstl_stoptoken.h:285
t_CALLBACK & callback()
Return a reference to the stored callback.
Definition bslstl_stoptoken.h:884
StopCallback_CallbackStorage(const allocator_type &allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG) arg)
Definition bslstl_stoptoken.h:855
Definition bslstl_stoptoken.h:218
Definition bslstl_stoptoken.h:357
StopCallback_Node(const t_ALLOC &allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG) arg)
Definition bslstl_stoptoken.h:944
Definition bslstl_stopstate.h:100
Definition bslstl_stopstate.h:121
#define BSLA_NODISCARD
Definition bsla_nodiscard.h:320
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_NOTHROW_SPEC
Definition bsls_exceptionutil.h:386
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:624
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:651
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:695
Definition bdlat_valuetypefunctions.h:939
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
const nostopstate_t nostopstate
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
Definition bslstl_algorithm.h:84
Definition bslmf_conditional.h:123
Definition bslmf_integralconstant.h:261
Definition bslmf_isreference.h:137
Definition bslstl_stoptoken.h:394
BSLS_KEYWORD_CONSTEXPR nostopstate_t() BSLS_KEYWORD_NOEXCEPT
Create a nostopstate_t value.
Definition bslstl_stoptoken.h:411
t_TYPE type
This typedef is an alias to the (template parameter) t_TYPE.
Definition bslmf_removereference.h:156
Definition bslma_usesbslmaallocator.h:344
Definition bslstl_stoptoken.h:245
bsls::AtomicUint64 d_stopSourceCount
Definition bslstl_stoptoken.h:251
Definition bsls_objectbuffer.h:277
TYPE * address()
Definition bsls_objectbuffer.h:335
TYPE & object()
Definition bsls_objectbuffer.h:352