-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restored one version of files removed in 9756756 while maintaining ca…
…se insensitivity support
- Loading branch information
Showing
2 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
src/ctre/include/ctre/phoenix/tasking/Schedulers/ConcurrentScheduler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include "ctre/phoenix/tasking/ILoopable.h" | ||
#include "ctre/phoenix/tasking/IProcessable.h" | ||
|
||
namespace ctre { | ||
namespace phoenix { | ||
/** tasking namespace */ | ||
namespace tasking { | ||
/** schedulers namespace */ | ||
namespace schedulers { | ||
|
||
/** | ||
* Scheduler that wil run its ILoopables in concurrency | ||
*/ | ||
class ConcurrentScheduler: public ILoopable, public IProcessable { | ||
public: | ||
/** Should be private */ | ||
std::vector<ILoopable*> _loops; | ||
/** Should be private */ | ||
std::vector<bool> _enabs; | ||
|
||
ConcurrentScheduler(); | ||
virtual ~ConcurrentScheduler(); | ||
/** | ||
* Add ILoopable to schedule | ||
* @param aLoop ILoopable to add to schedule | ||
* @param enable Whether to enable ILoopable | ||
*/ | ||
void Add(ILoopable *aLoop, bool enable = true); | ||
/** | ||
* Remove all ILoopables from scheduler | ||
*/ | ||
void RemoveAll(); | ||
/** | ||
* Start an ILoopable | ||
* @param toStart ILoopable to start | ||
*/ | ||
void Start(ILoopable *toStart); | ||
/** | ||
* Stop an ILoopable | ||
* @param toStop ILoopable to stop | ||
*/ | ||
void Stop(ILoopable *toStop); | ||
/** | ||
* Start all ILoopables | ||
*/ | ||
void StartAll(); | ||
/** | ||
* Stop all ILoopables | ||
*/ | ||
void StopAll(); | ||
|
||
//IProcessable | ||
/** | ||
* Process every ILoopable | ||
* | ||
* Call this every loop | ||
*/ | ||
void Process(); | ||
|
||
//ILoopable | ||
/** | ||
* @return false, this never iterates | ||
*/ | ||
bool Iterated(); | ||
/** | ||
* Start all ILoopables | ||
*/ | ||
void OnStart(); | ||
/** | ||
* Process all ILoopables | ||
*/ | ||
void OnLoop(); | ||
/** | ||
* Stop all ILoopables | ||
*/ | ||
void OnStop(); | ||
/** | ||
* @return false, this is never done | ||
*/ | ||
bool IsDone(); | ||
}; | ||
} | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/ctre/include/ctre/phoenix/tasking/Schedulers/SequentialScheduler.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include "ctre/phoenix/tasking/ILoopable.h" | ||
#include "ctre/phoenix/tasking/IProcessable.h" | ||
|
||
namespace ctre { namespace phoenix { namespace tasking { namespace schedulers { | ||
|
||
/** | ||
* Scheduler that will run its ILoopables in sequence | ||
*/ | ||
class SequentialScheduler: public ILoopable, public IProcessable{ | ||
public: | ||
/** should be private */ | ||
bool _running = false; | ||
/** should be private */ | ||
std::vector<ILoopable*> _loops; | ||
/** should be private */ | ||
unsigned int _idx = 0; | ||
/** should be private */ | ||
bool _iterated = false; | ||
|
||
SequentialScheduler(); | ||
virtual ~SequentialScheduler(); | ||
|
||
/** | ||
* Add ILoopable to scheduler | ||
* @param aLoop ILoopable to add | ||
*/ | ||
void Add(ILoopable *aLoop); | ||
/** | ||
* Get the currently running ILoopable | ||
* @return null, not implemented | ||
*/ | ||
ILoopable * GetCurrent(); | ||
/** | ||
* Remove all ILoopables | ||
*/ | ||
void RemoveAll(); | ||
/** | ||
* Start next ILoopable | ||
*/ | ||
void Start(); | ||
/** | ||
* Stop every ILoopable | ||
*/ | ||
void Stop(); | ||
|
||
//IProcessable | ||
/** | ||
* Process the currently active ILoopable | ||
* | ||
* Call this every loop | ||
*/ | ||
void Process(); | ||
|
||
//ILoopable | ||
/** | ||
* Start next ILoopable | ||
*/ | ||
void OnStart(); | ||
/** | ||
* Process currently active ILoopable | ||
*/ | ||
void OnLoop(); | ||
/** | ||
* Stop all ILoopables | ||
*/ | ||
void OnStop(); | ||
/** | ||
* @return true when no longer running | ||
*/ | ||
bool IsDone(); | ||
}; | ||
}}}} |