oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Functions
ove::this_thread Namespace Reference

Free functions that operate on the currently running thread. More...

Functions

void sleep_ms (uint32_t ms) noexcept
 Suspend the calling thread for at least ms milliseconds. Plain-millisecond analog of std::this_thread::sleep_for.
 
template<typename Rep , typename Period >
void sleep_for (std::chrono::duration< Rep, Period > d) noexcept
 Suspend the calling thread for the given chrono duration. std::this_thread::sleep_for analog.
 
void yield () noexcept
 Voluntarily relinquish the CPU to another ready thread of equal or higher priority. std::this_thread::yield analog.
 
ove_thread_t self () noexcept
 
thread_id get_id () noexcept
 

Detailed Description

Free functions that operate on the currently running thread.

Mirrors std::this_thread::. Use these for sleep, yield, and self-identification from inside a thread entry function. Previously these lived as static members on Thread<> (e.g. Thread<>::sleep_ms(500)), which read as "an operation on a thread" when semantically it's "the current thread."

Function Documentation

◆ sleep_ms()

void ove::this_thread::sleep_ms ( uint32_t  ms)
inlinenoexcept

Suspend the calling thread for at least ms milliseconds. Plain-millisecond analog of std::this_thread::sleep_for.

Parameters
[in]msSleep duration in milliseconds. Pass 0 to yield for one scheduler tick.

◆ sleep_for()

template<typename Rep , typename Period >
void ove::this_thread::sleep_for ( std::chrono::duration< Rep, Period >  d)
inlinenoexcept

Suspend the calling thread for the given chrono duration. std::this_thread::sleep_for analog.

Template Parameters
RepUnderlying arithmetic type of d.
PeriodTick period of d.
Parameters
[in]dSleep duration; rounded down to whole milliseconds (the substrate's resolution).

◆ self()

ove_thread_t ove::this_thread::self ( )
inlinenoexcept
Returns
Raw C handle of the currently executing thread.

◆ get_id()

thread_id ove::this_thread::get_id ( )
inlinenoexcept
Returns
thread_id of the currently executing thread.