File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121template <int N>
2222class StaticThreadController : public Thread {
2323protected:
24- Thread thread[N];
24+ // since this is a static controller, the pointers themselves can be const
25+ // it should be distinguished from 'const Thread* thread[N]'
26+ Thread * const thread[N];
2527public:
2628 template <typename ... T>
27- StaticThreadController (T&& ... params) :
29+ StaticThreadController (T... params) :
2830 Thread (),
2931 thread{params...}
3032 {
@@ -40,8 +42,8 @@ class StaticThreadController: public Thread{
4042 {
4143 for (int i = 0 ; i < N; i++){
4244 // Is enabled? Timeout exceeded?
43- if (thread[i]. shouldRun ()){
44- thread[i]. run ();
45+ if (thread[i]-> shouldRun ()){
46+ thread[i]-> run ();
4547 }
4648 }
4749
@@ -54,12 +56,16 @@ class StaticThreadController: public Thread{
5456
5557 // Return the I Thread on the array
5658 // Returns nullptr if index is out of bounds
57- Thread* get (int index) { return (index >= 0 && index < N) ? &thread[index] : nullptr ; };
59+ Thread* get (int index) {
60+ return (index >= 0 && index < N) ? thread[index] : nullptr ;
61+ };
5862
5963 // Return the I Thread on the array
6064 // Doesn't perform any bounds checks and behaviour is
6165 // unpredictable in case of index > N
62- Thread& operator [](int index) { return thread[index]; };
66+ Thread& operator [](int index) {
67+ return *thread[index];
68+ };
6369};
6470
6571#endif
You can’t perform that action at this time.
0 commit comments