-
Notifications
You must be signed in to change notification settings - Fork 196
/
ThreadController.h
53 lines (38 loc) · 1.21 KB
/
ThreadController.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
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
ThreadController.h - Controlls a list of Threads with different timings
Basicaly, what it does is to keep track of current Threads and run when
necessary.
ThreadController is an extended class of Thread, because of that,
it allows you to add a ThreadController inside another ThreadController...
For instructions, go to https://github.com/ivanseidel/ArduinoThread
Created by Ivan Seidel Gomes, March, 2013.
Released into the public domain.
*/
#ifndef ThreadController_h
#define ThreadController_h
#include "Thread.h"
#include "inttypes.h"
#define MAX_THREADS 15
class ThreadController: public Thread{
protected:
Thread* thread[MAX_THREADS];
int cached_size;
public:
ThreadController(unsigned long _interval = 0);
// run() Method is overrided
void run();
// Adds a thread in the first available slot (remove first)
// Returns if the Thread could be added or not
bool add(Thread* _thread);
// remove the thread (given the Thread* or ThreadID)
void remove(int _id);
void remove(Thread* _thread);
// Removes all threads
void clear();
// Return the quantity of Threads
int size(bool cached = true);
// Return the I Thread on the array
// Returns NULL if none found
Thread* get(int index);
};
#endif