Skip to content

Commit

Permalink
Restored one version of files removed in 9756756 while maintaining ca…
Browse files Browse the repository at this point in the history
…se insensitivity support
  • Loading branch information
dkt01 committed Sep 6, 2023
1 parent 0e797f5 commit adaddf7
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 0 deletions.
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();
};
}
}
}
}
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();
};
}}}}

0 comments on commit adaddf7

Please sign in to comment.