CTRE Phoenix C++ 5.33.1
ConcurrentScheduler.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
4#include <vector>
7
8namespace ctre {
9namespace phoenix {
10/** tasking namespace */
11namespace tasking {
12/** schedulers namespace */
13namespace schedulers {
14
15/**
16 * Scheduler that wil run its ILoopables in concurrency
17 */
19public:
20 /** Should be private */
21 std::vector<ILoopable*> _loops;
22 /** Should be private */
23 std::vector<bool> _enabs;
24
27 /**
28 * Add ILoopable to schedule
29 * @param aLoop ILoopable to add to schedule
30 * @param enable Whether to enable ILoopable
31 */
32 void Add(ILoopable *aLoop, bool enable = true);
33 /**
34 * Remove all ILoopables from scheduler
35 */
36 void RemoveAll();
37 /**
38 * Start an ILoopable
39 * @param toStart ILoopable to start
40 */
41 void Start(ILoopable *toStart);
42 /**
43 * Stop an ILoopable
44 * @param toStop ILoopable to stop
45 */
46 void Stop(ILoopable *toStop);
47 /**
48 * Start all ILoopables
49 */
50 void StartAll();
51 /**
52 * Stop all ILoopables
53 */
54 void StopAll();
55
56 //IProcessable
57 /**
58 * Process every ILoopable
59 *
60 * Call this every loop
61 */
62 void Process();
63
64 //ILoopable
65 /**
66 * @return false, this never iterates
67 */
68 bool Iterated();
69 /**
70 * Start all ILoopables
71 */
72 void OnStart();
73 /**
74 * Process all ILoopables
75 */
76 void OnLoop();
77 /**
78 * Stop all ILoopables
79 */
80 void OnStop();
81 /**
82 * @return false, this is never done
83 */
84 bool IsDone();
85};
86}
87}
88}
89}
Interface for loopable objects.
Definition: ILoopable.h:9
Interface for processable objects.
Definition: IProcessable.h:8
Scheduler that wil run its ILoopables in concurrency.
Definition: ConcurrentScheduler.h:18
void Stop(ILoopable *toStop)
Stop an ILoopable.
std::vector< ILoopable * > _loops
Should be private.
Definition: ConcurrentScheduler.h:21
void RemoveAll()
Remove all ILoopables from scheduler.
void Add(ILoopable *aLoop, bool enable=true)
Add ILoopable to schedule.
std::vector< bool > _enabs
Should be private.
Definition: ConcurrentScheduler.h:23
void Start(ILoopable *toStart)
Start an ILoopable.
namespace ctre
Definition: paramEnum.h:5