Arduino-Scheduler
Portable Collaborative Multi-Tasking Scheduler for Arduino
SchedulerClass Class Reference

#include <Scheduler.h>

Collaboration diagram for SchedulerClass:
Collaboration graph

Classes

struct  task_t
 

Public Types

typedef void(* func_t) ()
 

Static Public Member Functions

static bool begin (size_t stackSize)
 
static bool start (func_t taskSetup, func_t taskLoop, size_t stackSize=DEFAULT_STACK_SIZE)
 
static bool startLoop (func_t taskLoop, size_t stackSize=DEFAULT_STACK_SIZE)
 
static void yield ()
 
static size_t stack ()
 

Static Protected Member Functions

static void init (func_t setup, func_t loop, const uint8_t *stack)
 

Static Protected Attributes

static task_t s_main
 
static task_ts_running = &SchedulerClass::s_main
 
static size_t s_top = SchedulerClass::DEFAULT_MAIN_STACK_SIZE
 

Detailed Description

Definition at line 26 of file Scheduler.h.

Member Typedef Documentation

typedef void(* SchedulerClass::func_t) ()

Function prototype (task setup and loop functions).

Definition at line 31 of file Scheduler.h.

Member Function Documentation

bool SchedulerClass::begin ( size_t  stackSize)
static

Initiate scheduler and main task with given stack size. Should be called before start of any tasks if the main task requires a stack size other than the default main size. Returns true if successful otherwise false.

Parameters
[in]stackSizein bytes.
Returns
bool.

Definition at line 69 of file Scheduler.cpp.

void SchedulerClass::init ( func_t  setup,
func_t  loop,
const uint8_t *  stack 
)
staticprotected

Initiate a task with the given functions and stack. When control is yield to the task the setup function is first called and then the loop function is repeatedly called.

Parameters
[in]setuptask function (may be NULL).
[in]looptask function (may not be NULL).
[in]stacktop reference.

Definition at line 135 of file Scheduler.cpp.

size_t SchedulerClass::stack ( )
static

Return minimum remaining stack in bytes for running task. The value depends on executed function call depth and interrupt service routines during the execution (so far).

Returns
bytes

Definition at line 127 of file Scheduler.cpp.

bool SchedulerClass::start ( func_t  taskSetup,
func_t  taskLoop,
size_t  stackSize = DEFAULT_STACK_SIZE 
)
static

Start a task with given functions and stack size. Should be called from main task (in setup). The functions are executed by the task. The taskSetup function (if provided) is run once. The taskLoop function is repeatedly called. The taskSetup may be omitted (NULL). Returns true if successful otherwise false.

Parameters
[in]taskSetupfunction (may be NULL).
[in]taskLoopfunction (may not be NULL).
[in]stackSizein bytes.
Returns
bool.

Definition at line 76 of file Scheduler.cpp.

static bool SchedulerClass::startLoop ( func_t  taskLoop,
size_t  stackSize = DEFAULT_STACK_SIZE 
)
inlinestatic

Start a task with given taskLoop function and stack size. Should be called from main task (in setup). The taskLoop function is repeatedly called. Returns true if successful otherwise false.

Parameters
[in]taskLoopfunction.
[in]stackSizein bytes.
Returns
bool.

Definition at line 65 of file Scheduler.h.

void SchedulerClass::yield ( )
static

Context switch to next task in run queue.

Definition at line 117 of file Scheduler.cpp.

Member Data Documentation

SchedulerClass::task_t SchedulerClass::s_main
staticprotected
Initial value:

Main task.

Definition at line 144 of file Scheduler.h.

SchedulerClass::task_t * SchedulerClass::s_running = &SchedulerClass::s_main
staticprotected

Running task.

Definition at line 147 of file Scheduler.h.

size_t SchedulerClass::s_top = SchedulerClass::DEFAULT_MAIN_STACK_SIZE
staticprotected

Task stack allocation top.

Definition at line 150 of file Scheduler.h.


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