modm API documentation
modm::fiber::Task Class Reference

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

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

Public Member Functions

template<size_t Size, class T >
 Task (Stack< Size > &stack, T &&closure, Start start=Start::Now)
 
void watermark_stack ()
 
size_t stack_usage () const
 
bool stack_overflow () const
 
bool start ()
 
bool isRunning () const
 

Friends

class Scheduler
 

Detailed Description

The fiber task connects the callable fiber object with the fiber context and scheduler. It constructs the fiber function on the stack if necessary, and adds the contexts to the scheduler. If the fiber function returns, the task is removed from the scheduler. Tasks can then be restarted, which will call the fiber function from the beginning again

Note that a task contains no stack, only the control structures necessary for managing a fiber. You may therefore place objects of this class in fast core-local memory, while the stack must remain in DMA-able memory!

Author
Erik Henriksson
Niklas Hauser

Constructor & Destructor Documentation

template<size_t Size, class T >
modm::fiber::Task::Task ( Stack< Size > &  stack,
T &&  closure,
Start  start = Start::Now 
)
Parameters
stackA stack object that is NOT shared with other tasks.
closureA callable object of signature void(*)().
startWhen to start this task.

Member Function Documentation

bool modm::fiber::Task::isRunning ( ) const
inline
Returns
if the fiber is attached to a scheduler.
bool modm::fiber::Task::stack_overflow ( ) const
inline
Returns
if the bottom word on the stack has been overwritten.
See also
modm_context_stack_overflow().
size_t modm::fiber::Task::stack_usage ( ) const
inline
Returns
the stack usage as measured by a watermark level.
See also
modm_context_stack_usage().
bool modm::fiber::Task::start ( )

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

Returns
if the fiber has been scheduled.
void modm::fiber::Task::watermark_stack ( )
inline

Watermarks the stack to measure stack_usage() later.

See also
modm_context_watermark().

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