14#ifndef AMINO_CORE_STOP_TOKEN_H
15#define AMINO_CORE_STOP_TOKEN_H
21#include <Amino/Core/internal/PImpl.h>
22#include <Amino/Core/internal/StopCallbackDetails.h>
24#define AMINO_API AMINO_CORE_SHARED_DECL
71 return lhs.internal_equals(rhs);
74 return !lhs.internal_equals(rhs);
95 Internal::PImpl<StopToken, 1> m_impl;
135 return lhs.internal_equals(rhs);
138 return !lhs.internal_equals(rhs);
180template <typename Callback>
185 template <
typename C>
187 : Internal::StopCallbackImpl<Callback>{token, std::forward<C>(cb)} {}
189 template <
typename C>
191 : Internal::StopCallbackImpl<Callback>{
192 std::move(token), std::forward<C>(cb)} {}
211template <typename Callback>
213template <typename Callback>
Definition of macros for symbol visibility.
Forward declaration of classes in StopToken.h.
A tag type to indicate that a StopSource should be created without a valid state (such StopSource can...
A token that can be used to check if a stop has been requested.
AMINO_CORE_SHARED_DECL bool stopRequested() const
Check if a stop has been requested on the StopSource that was used to create this StopToken.
AMINO_CORE_SHARED_DECL bool stopPossible() const
Check if a stop can be requested on the StopSource that was used to create this StopToken.
friend bool operator!=(StopToken const &lhs, StopToken const &rhs)
Equality operators.
AMINO_CORE_SHARED_DECL StopToken() noexcept
Default constructor (constructs an invalid StopToken that can't be stopped).
A source that can be used to request a stop.
AMINO_CORE_SHARED_DECL StopSource & operator=(StopSource const &o)
Copy assignment operator.
AMINO_CORE_SHARED_DECL bool stopRequested() const
Check if a stop has been requested for this StopSource.
AMINO_CORE_SHARED_DECL StopSource(NoStopState_t) noexcept
Construct a non-stoppable StopSource.
AMINO_CORE_SHARED_DECL StopToken getToken() const noexcept
Get a StopToken that can be used to check if a stop has been requested from this StopSource.
AMINO_CORE_SHARED_DECL StopSource()
Default constructor (constructs a valid StopSource).
AMINO_CORE_SHARED_DECL StopSource(StopSource const &o)
Copy constructor.
AMINO_CORE_SHARED_DECL ~StopSource()
Destructor.
AMINO_CORE_SHARED_DECL StopSource & operator=(StopSource &&o) noexcept
Move assignment operator.
friend bool operator==(StopSource const &lhs, StopSource const &rhs)
Equality operators.
AMINO_CORE_SHARED_DECL void requestStop() noexcept
Request a stop.
AMINO_CORE_SHARED_DECL StopSource(StopSource &&o) noexcept
Move constructor.
friend bool operator!=(StopSource const &lhs, StopSource const &rhs)
Equality operators.
AMINO_CORE_SHARED_DECL bool stopPossible() const
Check if a stop can be requested for this StopSource.
A callback that can be attached to a StopToken.
StopCallback(StopCallback &&) noexcept=delete
StopCallback is not copyable nor movable.
StopCallback(StopToken &&token, C &&cb)
Constructor.
StopCallback(StopToken const &token, C &&cb)
Constructor.
StopCallback(StopCallback const &)=delete
StopCallback is not copyable nor movable.