-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskScheduler.h
40 lines (31 loc) · 928 Bytes
/
TaskScheduler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Copyright 2011 Alan Burlison, alan@bleaklow.com. All rights reserved.
* Use is subject to license terms.
*/
/*
* A simple priority-based task scheduler.
*/
#ifndef TaskScheduler_h
#define TaskScheduler_h
#include "Task.h"
// Calculate the number of tasks in the array, given the size.
#define NUM_TASKS(T) (sizeof(T) / sizeof(Task))
class TaskScheduler {
public:
/*
* Create a new task scheduler. Tasks are scheduled in priority order,
* where the highest priority task is first in the array, and the lowest
* priority task is the last.
* task - array of task pointers.
* numTasks - number of tasks in the array.
*/
TaskScheduler(Task **task, uint8_t numTasks);
/*
* Start the task scheduler running. Never returns.
*/
void run();
private:
Task **tasks; // Array of task pointers.
int numTasks; // Number of tasks in the array.
};
#endif