Lely core libraries  2.3.4
lely::util::StopToken Class Reference

An object providing the means to check if a stop request has been made for its associated lely::util::StopSource object. More...

#include <stop.hpp>

Public Member Functions

 StopToken () noexcept=default
 Constructs an empty stop token with no assiociated stop-state. More...
 
 StopToken (const StopToken &other) noexcept
 Constructs a stop token whose associated stop-state is the same as that if other. More...
 
 StopToken (StopToken &&other) noexcept
 Constructs a stop token whose associated stop-state is the same as that if other; other is left as valid stop token with no associated stop-state. More...
 
StopTokenoperator= (const StopToken &other) noexcept
 Copy-assigns the stop-state of other to *this. More...
 
StopTokenoperator= (StopToken &&other) noexcept
 Move-assigns the stop-state of other to *this. More...
 
 ~StopToken ()
 Destroys a stop token. More...
 
 operator bool () const noexcept
 Returns true if *this has a stop-state, and false otherwise.
 
bool stop_requested () const noexcept
 Returns true if *this has a stop-state and it has received a stop request, and false otherwise. More...
 
bool stop_possible () const noexcept
 Returns true if *this has a stop-state and it has received a stop request, or if it has an associated stop source that can still issue such a request, and false otherwise. More...
 
void swap (StopToken &other) noexcept
 Exchanges the stop-state of *this and other/.
 

Friends

bool operator== (const StopToken &lhs, const StopToken &rhs) noexcept
 Returns true if lhs and rhs have the same stop-state, and false otherwise.
 
bool operator!= (const StopToken &lhs, const StopToken &rhs) noexcept
 Returns false if lhs and rhs have the same stop-state, and true otherwise.
 
void swap (StopToken &lhs, StopToken &rhs) noexcept
 Exchanges the stop-state of lhs with rhs.
 

Detailed Description

An object providing the means to check if a stop request has been made for its associated lely::util::StopSource object.

It is essentially a thread-safe "view" of the associated stop-state.

Definition at line 40 of file stop.hpp.

Constructor & Destructor Documentation

◆ StopToken() [1/3]

lely::util::StopToken::StopToken ( )
defaultnoexcept

Constructs an empty stop token with no assiociated stop-state.

Postcondition
stop_possible() returns false.
stop_requested() returns false.

◆ StopToken() [2/3]

lely::util::StopToken::StopToken ( const StopToken other)
inlinenoexcept

Constructs a stop token whose associated stop-state is the same as that if other.

Postcondition
*this and other compare equal.
See also
stop_token_acquire()

Definition at line 60 of file stop.hpp.

◆ StopToken() [3/3]

lely::util::StopToken::StopToken ( StopToken &&  other)
inlinenoexcept

Constructs a stop token whose associated stop-state is the same as that if other; other is left as valid stop token with no associated stop-state.

Postcondition
other.stop_possible() returns false.

Definition at line 70 of file stop.hpp.

◆ ~StopToken()

lely::util::StopToken::~StopToken ( )
inline

Destroys a stop token.

If *this has a stop-state, its ownership is released.

See also
stop_token_release()

Definition at line 110 of file stop.hpp.

Member Function Documentation

◆ operator=() [1/2]

StopToken& lely::util::StopToken::operator= ( const StopToken other)
inlinenoexcept

Copy-assigns the stop-state of other to *this.

Postcondition
*this and other compare equal.
See also
stop_token_release(), stop_token_acquire().

Definition at line 82 of file stop.hpp.

◆ operator=() [2/2]

StopToken& lely::util::StopToken::operator= ( StopToken &&  other)
inlinenoexcept

Move-assigns the stop-state of other to *this.

After the assignment, *this contains the previous stop-state of other, and other has no stop-state.

Postcondition
other.stop_possible() returns false.

Definition at line 98 of file stop.hpp.

◆ stop_requested()

bool lely::util::StopToken::stop_requested ( ) const
inlinenoexcept

Returns true if *this has a stop-state and it has received a stop request, and false otherwise.

See also
stop_token_stop_requested()

Definition at line 124 of file stop.hpp.

◆ stop_possible()

bool lely::util::StopToken::stop_possible ( ) const
inlinenoexcept

Returns true if *this has a stop-state and it has received a stop request, or if it has an associated stop source that can still issue such a request, and false otherwise.

See also
stop_token_stop_possible()

Definition at line 136 of file stop.hpp.


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