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

An object providing the means to issue a stop request. More...

#include <stop.hpp>

Public Member Functions

 StopSource ()
 Constructs a stop source with a new stop-state. More...
 
 StopSource (stop_source_t *source) noexcept
 Constructs an empty stop source with no assiociated stop-state. More...
 
 StopSource (const StopSource &other) noexcept
 Constructs a stop source whose associated stop-state is the same as that if other. More...
 
 StopSource (StopSource &&other) noexcept
 Constructs a stop source whose associated stop-state is the same as that if other; other is left as valid stop source with no associated stop-state. More...
 
StopSourceoperator= (const StopSource &other) noexcept
 Copy-assigns the stop-state of other to *this. More...
 
StopSourceoperator= (StopSource &&other) noexcept
 Move-assigns the stop-state of other to *this. More...
 
 ~StopSource ()
 Destroys a stop source. More...
 
 operator bool () const noexcept
 Returns true if *this has a stop-state, and false otherwise.
 
bool request_stop () noexcept
 Issues a stop requests to the stop-state, if *this has a stop-state` and it has not already received a stop request. More...
 
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 false otherwise.
 
void swap (StopSource &other) noexcept
 Exchanges the stop-state of *this and other/.
 
StopToken get_token () const noexcept
 Returns a stop token associated with the stop-state of *this, if it has any, and a default-constructed (empty) stop token otherwise.
 

Friends

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

Detailed Description

An object providing the means to issue a stop request.

A stop request is visible to all lely::util::StopSource and lely::util::StopToken objects of the same associated stop-state.

Definition at line 179 of file stop.hpp.

Constructor & Destructor Documentation

◆ StopSource() [1/4]

lely::util::StopSource::StopSource ( )
inline

Constructs a stop source with a new stop-state.

See also
stop_source_create()

Definition at line 186 of file stop.hpp.

◆ StopSource() [2/4]

lely::util::StopSource::StopSource ( stop_source_t source)
inlineexplicitnoexcept

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

Postcondition
stop_possible() returns false.

Definition at line 195 of file stop.hpp.

◆ StopSource() [3/4]

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

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

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

Definition at line 205 of file stop.hpp.

◆ StopSource() [4/4]

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

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

Postcondition
other.stop_possible() returns false.

Definition at line 215 of file stop.hpp.

◆ ~StopSource()

lely::util::StopSource::~StopSource ( )
inline

Destroys a stop source.

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

See also
stop_source_release()

Definition at line 254 of file stop.hpp.

Member Function Documentation

◆ operator=() [1/2]

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

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

Postcondition
*this and other compare equal.
See also
stop_source_release(), stop_source_acquire().

Definition at line 227 of file stop.hpp.

◆ operator=() [2/2]

StopSource& lely::util::StopSource::operator= ( StopSource &&  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 243 of file stop.hpp.

◆ request_stop()

bool lely::util::StopSource::request_stop ( )
inlinenoexcept

Issues a stop requests to the stop-state, if *this has a stop-state` and it has not already received a stop request.

Once a stop is requested, it cannot be withdrawn. If a stop request is issued, any lely::util::StopCallback callbacks registered with a lely::util::StopToken with the same associated stop-state are invoked synchronously on the calling thread.

Returns
true if a stop request was issued, and false if not. In the latter case, another thread MAY still be in the middle of invoking a lely::util::StopCallback callback.
Postcondition
stop_possible() returns false or stop_requested() returns true.
See also
stop_source_request_stop()

Definition at line 278 of file stop.hpp.

◆ stop_requested()

bool lely::util::StopSource::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 289 of file stop.hpp.


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