28 #include <type_traits> 29 #include <propeller.h> 86 static_assert(std::is_base_of<Runnable, T>::value,
87 "Only PropWare::Runnable and its children can be invoked");
88 #pragma GCC diagnostic push 89 #pragma GCC diagnostic ignored "-Wpmf-conversions" 90 return (int8_t) cogstart((
void (*)(
void *)) &T::run, (
void *) &runnable,
91 (
void *) (runnable.m_stack), runnable.m_stackSizeInBytes);
92 #pragma GCC diagnostic pop 99 virtual void run() = 0;
108 Runnable(
const uint32_t (&stack)[N])
109 : m_stack(stack), m_stackSizeInBytes(N *
sizeof(uint32_t)) {
128 Runnable(
const uint32_t *stack,
const size_t stackLength)
129 : m_stack(stack), m_stackSizeInBytes(stackLength *
sizeof(uint32_t)) {
133 const uint32_t *m_stack;
134 size_t m_stackSizeInBytes;
static int8_t invoke(T &runnable)
Start a new cog running the given object.
Generic definitions and functions for the Parallax Propeller.
virtual void run()=0
Invoked in the new cog, this method should be the root of the business logic.
Helper class for creating easy parallel applications.