modm API documentation
|
A very lightweight, stackless thread. More...
#include <modm/processing/protothread/protothread.hpp>
Public Member Functions | |
Protothread () | |
Construct a new protothread that will start from the beginning of its run() function. | |
void | restart () |
Restart protothread. | |
void | stop () |
Stop the protothread from running. More... | |
bool | isRunning () const |
Check if the protothread is still running. More... | |
A very lightweight, stackless thread.
Because protothreads do not save the stack context across a blocking call, local variables are not preserved when the protothread blocks. This means that local variables should be used with utmost care - if in doubt, do not use local variables inside a protothread! Use private/protected member variables to save state between a context switch.
A protothread is driven by repeated calls to the run()-function in which the protothread is running. Each time the function is called, the protothread will run until it blocks or exits. Thus the scheduling of protothreads is done by the application that uses protothreads.
For other examples take a look in the examples
folder in the MODM root folder.
ptState
and ptYield
are reserved and may not be used as variables or function names!
|
inline |
Check if the protothread is still running.
true
if the protothread is running or waiting, false
if it has ended or exited.
|
inline |
Stop the protothread from running.
Happens automatically at PT_END.