modm API documentation
|
#include <modm/processing/fiber/task.hpp>
Public Member Functions | |
template<size_t Size, class Callable > | |
Task (Stack< Size > &stack, Callable &&closure, Start start=Start::Now) | |
modm::fiber::id | get_id () const |
bool | joinable () const |
Checks if the Task object identifies an active fiber of execution. | |
void | join () |
stop_source | get_stop_source () |
stop_token | get_stop_token () |
bool | request_stop () |
void | stack_watermark () |
size_t | stack_usage () const |
bool | start () |
bool | isRunning () const |
Static Public Member Functions | |
static constexpr unsigned int | hardware_concurrency () |
Returns the number of concurrent threads supported by the implementation. | |
Friends | |
class | Scheduler |
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!
modm::fiber::Task::Task | ( | Stack< Size > & | stack, |
Callable && | closure, | ||
Start | start = Start::Now |
||
) |
stack | A stack object that is NOT shared with other tasks. |
closure | A callable object of signature void() . |
start | When to start this task. |
|
nodiscardinline |
Returns a value of std::thread::id identifying the thread associated with *this
.
|
nodiscardinline |
|
inline |
Blocks the current fiber until the fiber identified by *this
finishes its execution. Returns immediately if the thread is not joinable.
|
inline |
|
nodiscardinline |
modm_context_stack_usage()
.
|
inline |
Watermarks the stack to measure stack_usage()
later.
modm_context_stack_watermark()
. bool modm::fiber::Task::start | ( | ) |
Adds the task to the currently active scheduler, if not already running.