C++ objects and CMake build system for Parallax Propeller
Public Member Functions | Static Public Member Functions | List of all members
PropWare::Runnable Class Referenceabstract

Helper class for creating easy parallel applications. More...

#include <PropWare/concurrent/runnable.h>

+ Inheritance diagram for PropWare::Runnable:

Public Member Functions

virtual void run ()=0
 Invoked in the new cog, this method should be the root of the business logic.

Static Public Member Functions

template<class T >
static int8_t invoke (T &runnable)
 Start a new cog running the given object. More...

Detailed Description

Helper class for creating easy parallel applications.

To create a Runnable instance which will blink an LED, try the simple example below:

template<size_t N>
BlinkingThread (const uint32_t (&stack)[N], const PropWare::Pin::Mask mask)
: Runnable(stack),
m_mask(mask) {}
void run () {
const PropWare::Pin pin(this->m_mask, PropWare::Pin::OUT);
while (1) {
waitcnt(250 * MILLISECOND + CNT);
const PropWare::Pin::Mask m_mask;
int main () {
uint32_t stack[64];
BlinkingThread blinkyThread(stack, PropWare::Pin::P16);
int8_t cog = PropWare::Runnable::invoke(blinkyThread);
pwOut << "Blink thread started in cog " << cog << "\n";
DualPWM_Demo.cpp, I2CSlave_Demo.cpp, Runnable_Demo.cpp, SynchronousPrinter_Demo.cpp, UARTRX_Demo.cpp, and WatchDog_Demo.cpp.

Definition at line 75 of file runnable.h.

Member Function Documentation

◆ invoke()

template<class T >
static int8_t PropWare::Runnable::invoke ( T runnable)

Start a new cog running the given object.

[in]runnableObject that should be invoked in a new cog
If the cog was successfully started, the new cog ID is returned. Otherwise, -1 is returned

Definition at line 85 of file runnable.h.

+ Here is the call graph for this function:

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