oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::stop_token Class Reference

Lightweight read-only handle to a thread's cooperative cancellation flag. More...

#include <thread.hpp>

Public Member Functions

constexpr stop_token (ove_thread_t h) noexcept
 
bool stop_requested () const noexcept
 
bool stop_possible () const noexcept
 
 operator bool () const noexcept
 Convertible to bool reflecting stop_requested.
 
ove_thread_t handle () const noexcept
 

Detailed Description

Lightweight read-only handle to a thread's cooperative cancellation flag.

Mirrors std::stop_token (C++20) but does NOT pull in the heavyweight <stop_token> header (which drags in <stop_source>, <stop_callback>, and condvar machinery — overkill for embedded). Trivially copyable; pass by value freely.

Workers built with the cooperative Thread constructor receive a stop_token as their entry argument:

[](ove::stop_token tok) {
while (!tok.stop_requested()) {
do_work();
}
},
OVE_PRIO_NORMAL, "worker");
RAII wrapper around an oveRTOS thread (task).
Definition thread.hpp:343
Lightweight read-only handle to a thread's cooperative cancellation flag.
Definition thread.hpp:57
bool stop_requested() const noexcept
Definition thread.hpp:65

The token can be passed to helper functions that need to bail out cooperatively. Setting the underlying flag is done via Thread::request_stop() or the parent's ~Thread(); the token is read-only by design.

See also
Thread, ove_thread_request_stop, ove_thread_should_stop

Member Function Documentation

◆ stop_requested()

bool ove::stop_token::stop_requested ( ) const
inlinenoexcept
Returns
true if a stop has been requested for the referenced thread.

◆ stop_possible()

bool ove::stop_token::stop_possible ( ) const
inlinenoexcept
Returns
true if the token references a real thread (non-default-constructed).

◆ operator bool()

ove::stop_token::operator bool ( ) const
inlineexplicitnoexcept

Convertible to bool reflecting stop_requested.

Enables if (tok) { … } shorthand. explicit prevents accidental implicit conversions in boolean-context-free positions.

◆ handle()

ove_thread_t ove::stop_token::handle ( ) const
inlinenoexcept
Returns
The raw ove_thread_t handle for advanced use.

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