You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sentence=Threding Library intended for use with multi-core ESP microcontrollers
6
+
paragraph=This library is intended to be used with the ESP32 and ESP32-S2 microcontrollers. It is designed to allow the user to very easily create and manage threads on the microcontroller. This library is intended to be used with PlatformIO and the Arduino framework.
// #define CORE_THREADING_DEBUG // Uncomment this to explicitly enable debugging for the threading module
4
+
#include<Arduino.h>
5
+
#include<cstdint>
6
+
7
+
namespaceESPressio {
8
+
9
+
enum ThreadState {
10
+
Uninitialized,
11
+
Initialized,
12
+
Running,
13
+
Paused,
14
+
Terminating,
15
+
Terminated,
16
+
Destroyed
17
+
};
18
+
19
+
/*
20
+
`IThread` is a common Interface for all Thread Types provided by this library.
21
+
You can use it to reference any Thread Type without knowing the actual type.
22
+
*/
23
+
classIThread {
24
+
public:
25
+
// Methods
26
+
27
+
/// `Initialize` is invoked automatically for all Threads when the `ThreadManager` is initialized in your `main()` (or `setup()` for MCU projects) function.
28
+
virtualvoidInitialize() = 0;
29
+
30
+
/*
31
+
`Terminate` is invoked automatically for all Threads when the `ThreadManager` is terminated in your `main()` (or `loop()` for MCU projects) function.
32
+
You can, however, invoke it manually to terminate a Thread at any time!
33
+
*/
34
+
virtualvoidTerminate() = 0;
35
+
36
+
/*
37
+
`Start` will start the Thread loop if it is not already running.
38
+
It will also Resume the thread if it is `Paused`.
39
+
*/
40
+
virtualvoidStart() = 0;
41
+
42
+
/// `Pause` will pause the Thread loop if it is running.
43
+
virtualvoidPause() = 0;
44
+
45
+
// Getters
46
+
47
+
/// `GetCoreID` returns the ID of the Core the Thread is running on.
48
+
virtual BaseType_t GetCoreID() = 0;
49
+
50
+
/// `GetStackSize` returns the size of the Stack the Thread is using.
51
+
virtualuint32_tGetStackSize() = 0;
52
+
53
+
/// `GetPriority` returns the priority of the Thread.
54
+
virtual UBaseType_t GetPriority() = 0;
55
+
56
+
/// `GetThreadID` returns the unique ID of the Thread.
57
+
virtualuint8_tGetThreadID() = 0;
58
+
59
+
/// `GetThreadState` returns the current state of the Thread.
60
+
virtual ThreadState GetThreadState() = 0;
61
+
62
+
/// `GetFreeOnTerminate` returns whether this Thread should be freed from memory when it is terminated.
63
+
virtualboolGetFreeOnTerminate() = 0;
64
+
65
+
/// `GetStartOnInitialize` returns whether this Thread should start running when it is initialized.
0 commit comments