idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::task::self Class Reference

Handle for task self-interaction. More...

Public Member Functions

 self (const self &)=delete
 
selfoperator= (const self &)=delete
 
bool is_detached () const noexcept
 Checks if the current task has been detached.
 
bool stop_requested () const noexcept
 Checks if a stop has been requested for this task.
 
void suspend () noexcept
 Suspends the current task.
 
void wait () noexcept
 Waits for a notification (binary semaphore pattern).
 
template<typename Rep , typename Period >
bool wait_for (const std::chrono::duration< Rep, Period > &timeout) noexcept
 Waits for a notification with a timeout (binary semaphore pattern).
 
template<typename Clock , typename Duration >
bool wait_until (const std::chrono::time_point< Clock, Duration > &deadline) noexcept
 Waits for a notification until a deadline (binary semaphore pattern).
 
uint32_t take () noexcept
 Takes accumulated notifications (counting semaphore pattern).
 
template<typename Rep , typename Period >
uint32_t take_for (const std::chrono::duration< Rep, Period > &timeout) noexcept
 Takes accumulated notifications with a timeout (counting semaphore pattern).
 
template<typename Clock , typename Duration >
uint32_t take_until (const std::chrono::time_point< Clock, Duration > &deadline) noexcept
 Takes accumulated notifications until a deadline (counting semaphore pattern).
 
unsigned int priority () const noexcept
 Returns the current task priority.
 
void set_priority (unsigned int new_priority) noexcept
 Changes the current task priority.
 
size_t stack_high_water_mark () const noexcept
 Returns the minimum free stack space (in bytes) since the task started.
 
std::string name () const
 Returns the current task name.
 
TaskHandle_t idf_handle () const noexcept
 Returns the FreeRTOS handle of the current task.
 

Friends

class task
 

Detailed Description

Handle for task self-interaction.

Provides access to the current task's own state within the task function.

Definition at line 57 of file task.hpp.

Constructor & Destructor Documentation

◆ self()

idfxx::task::self::self ( const self )
delete

Member Function Documentation

◆ idf_handle()

TaskHandle_t idfxx::task::self::idf_handle ( ) const
noexcept

Returns the FreeRTOS handle of the current task.

Returns
The current task's TaskHandle_t.

◆ is_detached()

bool idfxx::task::self::is_detached ( ) const
noexcept

Checks if the current task has been detached.

A detached task is self-managing: when the task function returns, the task cleans up its resources automatically.

Returns
true if the task has been detached or was spawned, false if still owned.

◆ name()

std::string idfxx::task::self::name ( ) const

Returns the current task name.

Returns
The task name.

◆ operator=()

self & idfxx::task::self::operator= ( const self )
delete

◆ priority()

unsigned int idfxx::task::self::priority ( ) const
noexcept

Returns the current task priority.

Returns
The task priority level.

◆ set_priority()

void idfxx::task::self::set_priority ( unsigned int  new_priority)
noexcept

Changes the current task priority.

Parameters
new_priorityThe new priority level.

◆ stack_high_water_mark()

size_t idfxx::task::self::stack_high_water_mark ( ) const
noexcept

Returns the minimum free stack space (in bytes) since the task started.

This is useful for tuning stack sizes — a value approaching zero indicates potential stack overflow.

Returns
The minimum free stack space in bytes since the task started running.

◆ stop_requested()

bool idfxx::task::self::stop_requested ( ) const
noexcept

Checks if a stop has been requested for this task.

Returns
true if request_stop() has been called on the owning task object, false otherwise.

◆ suspend()

void idfxx::task::self::suspend ( )
noexcept

Suspends the current task.

The task will not run again until another task calls resume() on it. If a stop has been requested, this method returns immediately without suspending.

◆ take()

uint32_t idfxx::task::self::take ( )
noexcept

Takes accumulated notifications (counting semaphore pattern).

Blocks until at least one notification is received. Returns the number of accumulated notifications and resets the count to zero. If a stop has been requested, returns 0 immediately without waiting.

Uses notification index 0, which is reserved for this purpose.

Returns
The number of accumulated notifications, or 0 if a stop was requested.

◆ take_for()

template<typename Rep , typename Period >
uint32_t idfxx::task::self::take_for ( const std::chrono::duration< Rep, Period > &  timeout)
inlinenoexcept

Takes accumulated notifications with a timeout (counting semaphore pattern).

Blocks until at least one notification is received or the timeout expires. Returns the number of accumulated notifications and resets the count to zero. If a stop has been requested, returns 0 immediately without waiting.

Uses notification index 0, which is reserved for this purpose.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
timeoutMaximum time to wait for notifications.
Returns
The number of accumulated notifications, or 0 if the timeout expired or a stop was requested.

Definition at line 173 of file task.hpp.

References idfxx::chrono::ticks(), and idfxx::timeout.

◆ take_until()

template<typename Clock , typename Duration >
uint32_t idfxx::task::self::take_until ( const std::chrono::time_point< Clock, Duration > &  deadline)
inlinenoexcept

Takes accumulated notifications until a deadline (counting semaphore pattern).

Blocks until at least one notification is received or the deadline is reached. Returns the number of accumulated notifications and resets the count to zero. If a stop has been requested, returns 0 immediately without waiting.

Uses notification index 0, which is reserved for this purpose.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
deadlineThe time point at which to stop waiting.
Returns
The number of accumulated notifications, or 0 if the deadline was reached or a stop was requested.

Definition at line 193 of file task.hpp.

References idfxx::chrono::ticks().

◆ wait()

void idfxx::task::self::wait ( )
noexcept

Waits for a notification (binary semaphore pattern).

Blocks until another task calls notify() or notify_from_isr(). If a stop has been requested, returns immediately without waiting.

Uses notification index 0, which is reserved for this purpose.

◆ wait_for()

template<typename Rep , typename Period >
bool idfxx::task::self::wait_for ( const std::chrono::duration< Rep, Period > &  timeout)
inlinenoexcept

Waits for a notification with a timeout (binary semaphore pattern).

Blocks until a notification is received or the timeout expires. If a stop has been requested, returns immediately without waiting.

Uses notification index 0, which is reserved for this purpose.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
timeoutMaximum time to wait for a notification.
Returns
true if a notification was received, false if the timeout expired or a stop was requested.

Definition at line 117 of file task.hpp.

References idfxx::chrono::ticks(), and idfxx::timeout.

◆ wait_until()

template<typename Clock , typename Duration >
bool idfxx::task::self::wait_until ( const std::chrono::time_point< Clock, Duration > &  deadline)
inlinenoexcept

Waits for a notification until a deadline (binary semaphore pattern).

Blocks until a notification is received or the deadline is reached. If a stop has been requested, returns immediately without waiting.

Uses notification index 0, which is reserved for this purpose.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
deadlineThe time point at which to stop waiting.
Returns
true if a notification was received, false if the deadline was reached or a stop was requested.

Definition at line 136 of file task.hpp.

References idfxx::chrono::ticks().

Friends And Related Symbol Documentation

◆ task

friend class task
friend

Definition at line 58 of file task.hpp.


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