8#ifndef INCLUDED_BSLSTL_STOPTOKEN
9#define INCLUDED_BSLSTL_STOPTOKEN
178#include <bsla_nodiscard.h>
200template <
class t_CALLBACK>
class stop_callback;
218 template <
class t_CALLBACK>
259template <
class t_CALLBACK,
279 BloombergLP::bslma::UsesBslmaAllocator<t_CALLBACK>::value,
289 template <
class t_ARG>
293 template <
class t_ARG>
313template <
class t_CALLBACK>
318 t_CALLBACK d_callback;
329 template <
class t_ARG>
332 template <
class t_ARG>
339 typename bsl::remove_reference<t_CALLBACK>::type&
callback()
const;
350template <
class t_CALLBACK>
367 template <
class t_ALLOC,
class t_ARG>
370 template <
class t_ALLOC,
class t_ARG>
410#if defined(BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES)
431 typedef BloombergLP::bslstl::StopToken_RefCountedState RefCountedState;
432 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
442 template <
class t_CALLBACK>
453 return lhs.d_state_p == rhs.d_state_p;
456#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
464 return lhs.d_state_p != rhs.d_state_p;
474 lhs.d_state_p.swap(rhs.d_state_p);
560 typedef BloombergLP::bslstl::StopToken_RefCountedState RefCountedState;
561 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
578 return lhs.d_state_p == rhs.d_state_p;
581#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
589 return lhs.d_state_p != rhs.d_state_p;
599 lhs.d_state_p.swap(rhs.d_state_p);
620 stop_source(BloombergLP::bslmf::MovableRef<stop_source> original)
697template <class t_CALLBACK>
702 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
709 BloombergLP::bslstl::StopCallback_Node<t_CALLBACK> d_node;
732 typedef typename BloombergLP::bslstl::StopCallback_Node<
749 template <
class t_ARG>
754 template <
class t_ARG>
756 BloombergLP::bslmf::MovableRef<stop_token> token,
759 template <
class t_ARG>
764 template <
class t_ARG>
766 BloombergLP::bslmf::MovableRef<stop_token> token,
786#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
788template <
class t_CALLBACK>
795template <
class t_CALLBACK>
813inline StopCallback_NoAlloc::StopCallback_NoAlloc()
822template <
class t_CALLBACK,
bool t_IS_REFERENCE>
824StopCallback_CallbackStorage<t_CALLBACK, t_IS_REFERENCE>::mechanism(
830template <
class t_CALLBACK,
bool t_IS_REFERENCE>
831void *StopCallback_CallbackStorage<t_CALLBACK, t_IS_REFERENCE>::mechanism(
832 const StopCallback_NoAlloc&)
837template <
class t_CALLBACK,
bool t_IS_REFERENCE>
838template <
class t_ARG>
844 BloombergLP::bslma::ConstructionUtil::construct(
846 mechanism(allocator),
850template <
class t_CALLBACK,
bool t_IS_REFERENCE>
851template <
class t_ARG>
855 BloombergLP::bslma::ConstructionUtil::construct(d_buf.
address(),
856 mechanism(allocator),
860template <
class t_CALLBACK,
bool t_IS_REFERENCE>
862 t_IS_REFERENCE>::~StopCallback_CallbackStorage()
864 BloombergLP::bslma::DestructionUtil::destroy(d_buf.
address());
867template <
class t_CALLBACK,
bool t_IS_REFERENCE>
874template <
class t_CALLBACK,
bool t_IS_REFERENCE>
885template <
class t_CALLBACK>
886template <
class t_ARG>
894template <
class t_CALLBACK>
895template <
class t_ARG>
903template <
class t_CALLBACK>
904typename bsl::remove_reference<t_CALLBACK>::type&
914template <
class t_CALLBACK>
919#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
920 std::forward<t_CALLBACK>(
927template <
class t_CALLBACK>
928template <
class t_ALLOC,
class t_ARG>
930 const t_ALLOC& allocator,
938template <
class t_CALLBACK>
939template <
class t_ALLOC,
class t_ARG>
956: d_state_p(MoveUtil::move(state))
969: d_state_p(original.d_state_p)
974stop_token::stop_token(BloombergLP::bslmf::MovableRef<stop_token> original)
976: d_state_p(MoveUtil::move(MoveUtil::access(original).d_state_p))
981stop_token::~stop_token()
990 d_state_p = other.d_state_p;
998 d_state_p = MoveUtil::move(MoveUtil::access(other).d_state_p);
1005 d_state_p.
swap(other.d_state_p);
1020stop_source::stop_source(BloombergLP::bslmf::MovableRef<stop_source> original)
1022: d_state_p(MoveUtil::move(MoveUtil::access(original).d_state_p))
1030 d_state_p.
swap(other.d_state_p);
1038template <
class t_CALLBACK>
1041 if (d_state_p && !d_state_p->enregister(&d_node)) {
1047template <
class t_CALLBACK>
1048template <
class t_ARG>
1054, d_state_p(token.d_state_p)
1059template <
class t_CALLBACK>
1060template <
class t_ARG>
1062 BloombergLP::bslmf::MovableRef<stop_token> token,
1066, d_state_p(MoveUtil::move(MoveUtil::access(token).d_state_p))
1071template <
class t_CALLBACK>
1072template <
class t_ARG>
1077, d_state_p(token.d_state_p)
1082template <
class t_CALLBACK>
1083template <
class t_ARG>
1085 BloombergLP::bslmf::MovableRef<stop_token> token,
1089, d_state_p(MoveUtil::move(MoveUtil::access(token).d_state_p))
1094template <
class t_CALLBACK>
1098 d_state_p->deregister(&d_node);
1102template <
class t_CALLBACK>
1106 return d_node.callback().get_allocator();
Definition bslma_bslallocator.h:580
BloombergLP::bslma::Allocator * mechanism() const
Definition bslma_bslallocator.h:1126
Definition bslstl_sharedptr.h:1830
void swap(shared_ptr &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5425
void reset() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5358
Definition bslstl_stoptoken.h:698
t_CALLBACK callback_type
Definition bslstl_stoptoken.h:728
~stop_callback()
Definition bslstl_stoptoken.h:1095
BloombergLP::bslstl::StopCallback_Node< t_CALLBACK >::allocator_type allocator_type
Definition bslstl_stoptoken.h:733
allocator_type get_allocator() const
Definition bslstl_stoptoken.h:1104
Definition bslstl_stoptoken.h:556
friend void swap(stop_source &lhs, stop_source &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:597
~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:585
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:574
Definition bslstl_stoptoken.h:427
BSLA_NODISCARD friend bool operator==(const stop_token &lhs, const stop_token &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:449
BSLA_NODISCARD friend bool operator!=(const stop_token &lhs, const stop_token &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:460
friend class stop_source
Definition bslstl_stoptoken.h:440
friend class stop_callback
Definition bslstl_stoptoken.h:443
stop_token & operator=(const stop_token &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:987
friend void swap(stop_token &lhs, stop_token &rhs) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stoptoken.h:472
stop_token() BSLS_KEYWORD_NOEXCEPT
Create a stop_token object that does not refer to a stop state.
Definition bslstl_stoptoken.h:962
BSLA_NODISCARD bool stop_possible() const BSLS_KEYWORD_NOEXCEPT
BSLA_NODISCARD bool stop_requested() const BSLS_KEYWORD_NOEXCEPT
Definition bslma_allocator.h:457
Definition bsls_atomic.h:1195
StopCallback_NoAlloc allocator_type
Definition bslstl_stoptoken.h:322
Definition bslstl_stoptoken.h:261
~StopCallback_CallbackStorage()
Destroy this object.
Definition bslstl_stoptoken.h:862
bsl::conditional< BloombergLP::bslma::UsesBslmaAllocator< t_CALLBACK >::value, bsl::allocator< char >, StopCallback_NoAlloc >::type allocator_type
Definition bslstl_stoptoken.h:281
t_CALLBACK & callback()
Return a reference to the stored callback.
Definition bslstl_stoptoken.h:869
StopCallback_CallbackStorage(const allocator_type &allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG) arg)
Definition bslstl_stoptoken.h:840
Definition bslstl_stoptoken.h:214
Definition bslstl_stoptoken.h:352
StopCallback_Node(const t_ALLOC &allocator, BSLS_COMPILERFEATURES_FORWARD_REF(t_ARG) arg)
Definition bslstl_stoptoken.h:929
Definition bslstl_stopstate.h:98
Definition bslstl_stopstate.h:119
#define BSLA_NODISCARD
Definition bsla_nodiscard.h:320
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_NOTHROW_SPEC
Definition bsls_exceptionutil.h:386
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:588
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:609
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:653
Definition bdlb_printmethods.h:283
const nostopstate_t nostopstate
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
Definition bslstl_algorithm.h:82
Definition bslmf_conditional.h:120
Definition bslmf_integralconstant.h:244
Definition bslmf_isreference.h:137
Definition bslstl_stoptoken.h:387
BSLS_KEYWORD_CONSTEXPR nostopstate_t() BSLS_KEYWORD_NOEXCEPT
Create a nostopstate_t value.
Definition bslstl_stoptoken.h:404
Definition bslma_usesbslmaallocator.h:343
Definition bslstl_stoptoken.h:241
bsls::AtomicUint64 d_stopSourceCount
Definition bslstl_stoptoken.h:247
Definition bsls_objectbuffer.h:276
TYPE * address()
Definition bsls_objectbuffer.h:334
TYPE & object()
Definition bsls_objectbuffer.h:351