Skip to content

Commit 0c405f3

Browse files
committed
update all additional stuff like README or examples
1 parent 29b2db4 commit 0c405f3

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ if(myThread.shouldRun()){
7979

8080
Now that you got the idea, let's think a little bit: What if i have 3, 5, 100 Threads. Do I need to check EACH one?!?
8181

82-
* The answer is: NO. Create a `ThreadController`, and put all your boring-complex Threads inside it!
82+
* The answer is: NO. Create a `ThreadController` or `StaticThreadController`,
83+
and put all your boring-complex Threads inside it!
8384

8485
```c++
8586
// Instantiate a new ThreadController
@@ -90,11 +91,18 @@ controller.add(&hisThread);
9091
controller.add(&sensorReadings);
9192
...
9293
```
94+
or
95+
```c++
96+
// Instantiate a new StaticThreadController
97+
StaticThreadController<2> controller (Thread(my_callback, my_interval), Thread(his_callback, his_interval));
98+
// You don't need to do anything else, the treads will be created and kept inside controller
99+
...
100+
```
93101
94102
* You have created, configured, grouped it. What is missing? Yes, whe should RUN it!
95103
96104
```c++
97-
// call run on a Thread or a ThreadController to run it
105+
// call run on a Thread, a ThreadController or a StaticThreadController to run it
98106
controller.run();
99107
```
100108

@@ -126,6 +134,11 @@ or disable a GROUP of Threads, think about putting all of them inside a ThreadCo
126134
and adding this ThreadController to another ThreadController (YES! One ThreadController
127135
inside another). Check `ControllerInController` example.
128136

137+
* There is a `StaticThreadController` which is better to use when you know exact number of
138+
threads to run. You cannot add or remove threads in runtime, but `StaticThreadController`
139+
doesn't have any memory overhead to keep all the treads together, also the code may be slighly
140+
more optimized because all the threads always exist and no need to do any runtime checks.
141+
129142
* Check the full example `CustomTimedThread` for a cool application of Threads that runs
130143
for a period, after a button is pressed.
131144

@@ -177,5 +190,12 @@ interrupts(); // This will enable the interrupts egain. DO NOT FORGET!
177190
inside the ThreadController. If cached is `false`, will force the calculation of threads.
178191
- `Thread* ThreadController::get(int index)` - Returns the Thread on the position `index`.
179192

193+
194+
- `void StaticThreadController::run()` - This will run the all `Threads` within the `StaicThreadController`,
195+
only if needed (if shouldRun returns true);
196+
- `int StaticThreadController::size()` - Returns how many Threads are allocated inside the StaticThreadController.
197+
- `Thread* ThreadController::get(int index)` - Returns the Thread on the position `index` and `nullptr` if `index`
198+
is out of bounds.
199+
180200
### You don't need to know:
181201
- Nothing, yet ;)

keywords.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
Thread KEYWORD1
1010
ThreadController KEYWORD1
11+
StaticThreadController KEYWORD1
1112

1213
#######################################
1314
# Methods and Functions (KEYWORD2)
@@ -19,7 +20,7 @@ shouldRun KEYWORD2
1920
onRun KEYWORD2
2021
run KEYWORD2
2122

22-
# Specific of ThreadController
23+
# Specific of ThreadController or StaticThreadController
2324
add KEYWORD2
2425
remove KEYWORD2
2526
clear KEYWORD2

0 commit comments

Comments
 (0)