modm API documentation
modm::pt::Protothread Class Reference
Inheritance diagram for modm::pt::Protothread:
modm::Fiber< MODM_PROTOTHREAD_STACK_SIZE > modm::fiber::Task modm::ds1631< I2cMaster > modm::Tmp102< I2cMaster > modm::Tmp175< I2cMaster >

Public Typedefs

using id = uintptr_t
 
using binary_semaphore = counting_semaphore< 1 >
 

Public Types

enum  Start
 

Public Member Functions

 Protothread (modm::fiber::Start start=modm::fiber::Start::Now)
 
void restart ()
 
void stop ()
 
virtual bool run ()
 
virtual bool update ()
 
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
 Alignment requirements for the bottom and top of the stack.
 
static constexpr size_t StackSizeDefault
 
static constexpr size_t StackSizeMinimum
 Minimum stack size required to push one full fiber context.
 
enum  cv_status
 
using condition_variable = condition_variable_any
 There is no specialization for std::unique_lock<fiber::mutex>.
 

Member Typedef Documentation

using modm::Fiber< fiber::StackSizeDefault >::binary_semaphore = counting_semaphore<1>
inherited

Implements the std::binary_semaphore interface for fibers.

See also
https://en.cppreference.com/w/cpp/thread/counting_semaphore
using modm::Fiber< fiber::StackSizeDefault >::id = uintptr_t
inherited

Identifier of a fiber task.

Member Enumeration Documentation

enum modm::Fiber::Start
inheritedstrong

The Fiber scheduling policy.

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.

Member Data Documentation

constexpr size_t modm::Fiber< fiber::StackSizeDefault >::StackSizeDefault
inheritedstaticconstexpr

The default stack size is estimated experimentally so that a fiber can use modm::IOStream to log out information, which is fairly stack intensive. Use modm::fiber::Task::stack_usage() to determine the real stack usage.


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