Lely core libraries
2.3.4
|
Go to the documentation of this file.
24 #ifndef LELY_UTIL_STOP_HPP_
25 #define LELY_UTIL_STOP_HPP_
71 other.token_ =
nullptr;
83 if (token_ != other.token_) {
100 swap(token_, other.token_);
112 operator stop_token_t*()
const noexcept {
return token_; }
115 explicit operator bool() const noexcept {
return token_ !=
nullptr; }
143 ::std::swap(token_, other.token_);
152 return lhs.token_ == rhs.token_;
161 return !(lhs == rhs);
187 if (!source_) util::throw_errc(
"StopSource");
216 other.source_ =
nullptr;
228 if (source_ != other.source_) {
259 explicit operator bool() const noexcept {
return source_ !=
nullptr; }
302 ::std::swap(source_, other.source_);
320 return lhs.source_ == rhs.source_;
329 return !(lhs == rhs);
348 template <
class Callback>
351 using callback_type = Callback;
406 ::std::forward<Callback>(cb_)();
416 #endif // !LELY_UTIL_STOP_HPP_
StopToken & operator=(const StopToken &other) noexcept
Copy-assigns the stop-state of other to *this.
stop_source_t * stop_source_create(void)
Creates a stop source with a new stop-state.
An object providing the means to issue a stop request.
int stop_source_request_stop(stop_source_t *source)
Issues a stop request to the stop-state associated with the specified stop source,...
An object providing the means to check if a stop request has been made for its associated lely::util:...
~StopToken()
Destroys a stop token.
StopCallback(StopToken &&token, C &&cb)
Moves the token stop token, saves the cb callback function and registers with with token.
friend bool operator==(const StopToken &lhs, const StopToken &rhs) noexcept
Returns true if lhs and rhs have the same stop-state, and false otherwise.
StopSource()
Constructs a stop source with a new stop-state.
void(* func)(struct stop_func *func)
The function to be invoked when a stop request is issued.
friend bool operator!=(const StopToken &lhs, const StopToken &rhs) noexcept
Returns false if lhs and rhs have the same stop-state, and true otherwise.
friend bool operator!=(const StopSource &lhs, const StopSource &rhs) noexcept
Returns false if lhs and rhs have the same stop-state, and true otherwise.
void stop_token_remove(stop_token_t *token, struct stop_func *func)
Deregisters a callback function from the specified stop token.
int stop_source_stop_requested(const stop_source_t *source)
Checks if the stop-state associated with the specified stop source has received a stop request.
StopSource & operator=(StopSource &&other) noexcept
Move-assigns the stop-state of other to *this.
StopToken & operator=(StopToken &&other) noexcept
Move-assigns the stop-state of other to *this.
bool request_stop() noexcept
Issues a stop requests to the stop-state, if *this has a stop-state` and it has not already received ...
StopSource & operator=(const StopSource &other) noexcept
Copy-assigns the stop-state of other to *this.
StopToken(const StopToken &other) noexcept
Constructs a stop token whose associated stop-state is the same as that if other.
friend bool operator==(const StopSource &lhs, const StopSource &rhs) noexcept
Returns true if lhs and rhs have the same stop-state, and false otherwise.
bool stop_possible() const noexcept
Returns true if *this has a stop-state, and false otherwise.
~StopSource()
Destroys a stop source.
void stop_source_release(stop_source_t *source)
Releases a reference to a stop source.
StopSource(StopSource &&other) noexcept
Constructs a stop source whose associated stop-state is the same as that if other; other is left as v...
void stop_token_release(stop_token_t *token)
Releases a reference to a stop token.
StopToken(StopToken &&other) noexcept
Constructs a stop token whose associated stop-state is the same as that if other; other is left as va...
StopToken get_token() const noexcept
Returns a stop token associated with the stop-state of *this, if it has any, and a default-constructe...
void swap(StopSource &other) noexcept
Exchanges the stop-state of *this and other/.
int stop_token_stop_requested(const stop_token_t *token)
Checks if the stop-state associated with the specified stop token has received a stop request.
stop_source_t * stop_source_acquire(stop_source_t *source)
Acquires a reference to a stop source.
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...
friend void swap(StopSource &lhs, StopSource &rhs) noexcept
Exchanges the stop-state of lhs with rhs.
StopSource(stop_source_t *source) noexcept
Constructs an empty stop source with no assiociated stop-state.
StopCallback(const StopToken &token, C &&cb)
Copies the token stop token, saves the cb callback function and registers with with token.
An object providing the means to register a callback function with an stop_token_t object.
A RAII object type that registers a callback function with a lely::util::StopToken object.
~StopCallback()
If *this has a lely::util::StopToken with associated stop-state, deregisters the saved callback funct...
friend void swap(StopToken &lhs, StopToken &rhs) noexcept
Exchanges the stop-state of lhs with rhs.
int stop_token_stop_possible(const stop_token_t *token)
Checks if the stop-state associated with the specified stop token has received a stop request,...
bool stop_requested() const noexcept
Returns true if *this has a stop-state and it has received a stop request, and false otherwise.
int stop_token_insert(stop_token_t *token, struct stop_func *func)
Registers a callback function with the specified stop token.
StopSource(const StopSource &other) noexcept
Constructs a stop source whose associated stop-state is the same as that if other.
stop_token_t * stop_source_get_token(stop_source_t *source)
Returns (a reference to) a stop token associated with the specified stop source's stop-state.
StopToken() noexcept=default
Constructs an empty stop token with no assiociated stop-state.
#define STOP_FUNC_INIT(func)
The static initializer for stop_func.
void swap(StopToken &other) noexcept
Exchanges the stop-state of *this and other/.
stop_token_t * stop_token_acquire(stop_token_t *token)
Acquires a reference to a stop token.
bool stop_requested() const noexcept
Returns true if *this has a stop-state and it has received a stop request, and false otherwise.