modm API documentation
modm::Fiber< StackSize > Class Template Reference

#include <modm/processing/fiber/task.hpp>

Inheritance diagram for modm::Fiber< StackSize >:
modm::fiber::Task

Public Typedefs

using id = uintptr_t
 
using binary_semaphore = counting_semaphore< 1 >
 

Public Types

enum  Start
 

Public Member Functions

template<class T >
 Fiber (T &&task, fiber::Start start=fiber::Start::Now)
 
modm::fiber::id get_id () const
 
stop_source get_stop_source ()
 
stop_token get_stop_token ()
 
bool isRunning () const
 
void join ()
 
bool joinable () const
 Checks if the Task object identifies an active fiber of execution.
 
bool request_stop ()
 
size_t stack_usage () const
 
void stack_watermark ()
 
bool start ()
 

Static Public Member Functions

static constexpr unsigned int hardware_concurrency ()
 Returns the number of concurrent threads supported by the implementation.
 

Static Public Attributes

static constexpr size_t StackAlignment = sizeof(uintptr_t) * 2
 Alignment requirements for the bottom and top of the stack.
 
static constexpr size_t StackSizeMinimum = 108
 Minimum stack size required to push one full fiber context.
 
static constexpr size_t StackSizeDefault = 1024
 
enum  cv_status
 
using condition_variable = condition_variable_any
 There is no specialization for std::unique_lock<fiber::mutex>.
 

Detailed Description

template<size_t StackSize = fiber::StackSizeDefault>
class modm::Fiber< StackSize >

This class is a convenience extension of a fiber task, which contains the modm::fiber::Stack as part of the class. The class is constructed at runtime only, therefore it is placed into the .bss section by default and does not count towards your .data section size. To speed up booting you may place the object into the modm_faststack section.

Member Typedef Documentation

template<size_t StackSize = fiber::StackSizeDefault>
using modm::Fiber< StackSize >::binary_semaphore = counting_semaphore<1>

Implements the std::binary_semaphore interface for fibers.

See also
https://en.cppreference.com/w/cpp/thread/counting_semaphore

Member Function Documentation

modm::fiber::id modm::fiber::Task::get_id ( ) const
inheritednodiscardinline

Returns a value of std::thread::id identifying the thread associated with *this.

Note
This function can be called from an interrupt.
bool modm::fiber::Task::isRunning ( ) const
inheritednodiscardinline
Returns
if the fiber is attached to a scheduler.
void modm::fiber::Task::join ( )
inheritedinline

Blocks the current fiber until the fiber identified by *this finishes its execution. Returns immediately if the thread is not joinable.

bool modm::fiber::Task::request_stop ( )
inheritedinline
Note
This function can be called from an interrupt.
size_t modm::fiber::Task::stack_usage ( ) const
inheritednodiscardinline
Returns
the stack usage as measured by a watermark level.
See also
modm_context_stack_usage().
void modm::fiber::Task::stack_watermark ( )
inheritedinline

Watermarks the stack to measure stack_usage() later.

See also
modm_context_stack_watermark().
bool modm::fiber::Task::start ( )
inherited

Adds the task to the currently active scheduler, if not already running.

Returns
if the fiber has been scheduled.

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