Manages a collection of schedulers, allowing addition, retrieval, and deletion of schedulers.
More...
#include <SchedulerContainer.hpp>
|
| | SchedulerContainer ()=default |
| | Default constructor for SchedulerContainer.
|
| | ~SchedulerContainer ()=default |
| | Destructor for SchedulerContainer.
|
| template<typename TScheduler, typename... Args> |
| void | AddScheduler (Core &core, Args &&...args) |
| | Adds a scheduler to the container.
|
| template<typename TScheduler> |
| TScheduler & | GetScheduler () |
| | Retrieves a scheduler of the specified type.
|
| std::shared_ptr< Scheduler::AScheduler > | GetScheduler (std::type_index id) |
| | Retrieves a scheduler identified by the given type index.
|
| void | RunSchedulers () |
| | Runs all schedulers in the container. This function iterates through the ordered list of schedulers and calls the RunSystems method on each scheduler. It ensures that the schedulers are executed in the order defined by their dependencies.
|
| template<typename TScheduler> |
| void | DeleteScheduler () |
| | Deletes a scheduler of the specified type.
|
| void | DeleteScheduler (std::type_index id) |
| | Deletes a scheduler identified by the given type index.
|
| template<typename TBefore, typename TAfter> |
| void | Before () |
| | Add a dependency between two schedulers. It will set the first scheduler to be before the second one.
|
| template<typename TAfter, typename TBefore> |
| void | After () |
| | Add a dependency between two schedulers. It will set the first scheduler to be after the second one.
|
| template<typename TBefore, typename TAfter> |
| void | RemoveDependencyBefore () |
| | Remove a dependency between two schedulers. It will remove the dependency that the first scheduler is before the second one.
|
| template<typename TAfter, typename TBefore> |
| void | RemoveDependencyAfter () |
| | Remove a dependency between two schedulers. It will remove the dependency that the first scheduler is after the second one.
|
| template<typename TScheduler> |
| bool | Contains () const |
| | Checks if a scheduler of the specified type exists in the container.
|
| bool | Contains (std::type_index id) const |
| | Checks if a scheduler identified by the given type index exists in the container.
|
| void | SetErrorPolicyForAllSchedulers (Scheduler::SchedulerErrorPolicy policy) |
| | Sets the error policy for all schedulers in the container.
|
|
| void | Update () |
| | Updates the order of schedulers based on their dependencies. This function performs a topological sort on the schedulers to determine the correct execution order. It checks for circular dependencies.
|
| void | TopologicalSort () |
| | Apply a topological sort between all schedulers based on their dependencies.
|
| void | ProcessDependencies (std::type_index current, std::queue< std::type_index > &q, std::map< std::type_index, size_t > &inDegree) const |
| | Helper function to process the dependencies of a scheduler during the topological sort. It updates the in-degree of the dependent schedulers and adds them to the queue if their in-degree becomes zero.
|
|
| bool | _dirty = false |
| | A flag indicating whether the order of schedulers needs to be updated.
|
| std::map< std::type_index, std::shared_ptr< Scheduler::AScheduler > > | _schedulers |
| | A map of the schedulers.
|
| std::unordered_map< std::type_index, std::unordered_set< std::type_index > > | _dependencies |
| | A map of the dependencies between schedulers. The key is the type index of a scheduler, and the value is a set of type indices of schedulers that depend on the key scheduler.
|
| std::list< std::shared_ptr< Scheduler::AScheduler > > | _orderedSchedulers |
| | A list of the the ordered list of schedulers.
|
Manages a collection of schedulers, allowing addition, retrieval, and deletion of schedulers.
- See also
- Engine::Scheduler::IScheduler
-
Engine::Scheduler::AScheduler
-
Engine::Scheduler::SchedulerError
◆ SchedulerContainer()
| Engine::SchedulerContainer::SchedulerContainer |
( |
| ) |
|
|
default |
◆ ~SchedulerContainer()
| Engine::SchedulerContainer::~SchedulerContainer |
( |
| ) |
|
|
default |
◆ AddScheduler()
template<typename TScheduler, typename... Args>
| void Engine::SchedulerContainer::AddScheduler |
( |
Core & | core, |
|
|
Args &&... | args ) |
Adds a scheduler to the container.
- Parameters
-
| core | A reference to the Core. |
| args | The arguments to be forwarded to the scheduler's constructor. |
- Template Parameters
-
| TScheduler | The type of the scheduler to be added. |
| Args | The types of the arguments to be forwarded to the scheduler's constructor. |
◆ After()
template<typename TAfter, typename TBefore>
| void Engine::SchedulerContainer::After |
( |
| ) |
|
|
inline |
Add a dependency between two schedulers. It will set the first scheduler to be after the second one.
- Template Parameters
-
| TAfter | The type of the first scheduler. |
| TBefore | The type of the second scheduler. |
◆ Before()
template<typename TBefore, typename TAfter>
| void Engine::SchedulerContainer::Before |
( |
| ) |
|
|
inline |
Add a dependency between two schedulers. It will set the first scheduler to be before the second one.
- Template Parameters
-
| TBefore | The type of the first scheduler. |
| TAfter | The type of the second scheduler. |
◆ Contains() [1/2]
template<typename TScheduler>
| bool Engine::SchedulerContainer::Contains |
( |
| ) |
const |
|
inline |
Checks if a scheduler of the specified type exists in the container.
- Template Parameters
-
| TScheduler | The type of the scheduler to check for. |
- Returns
- true if the scheduler exists, false otherwise.
◆ Contains() [2/2]
| bool Engine::SchedulerContainer::Contains |
( |
std::type_index | id | ) |
const |
|
inline |
Checks if a scheduler identified by the given type index exists in the container.
- Parameters
-
| id | The type index of the scheduler to check for. |
- Returns
- true if the scheduler exists, false otherwise.
◆ DeleteScheduler() [1/2]
template<typename TScheduler>
| void Engine::SchedulerContainer::DeleteScheduler |
( |
| ) |
|
|
inline |
Deletes a scheduler of the specified type.
- Template Parameters
-
| TScheduler | The type of the scheduler to be deleted. |
- Todo
- Put the implementation in the inl file
◆ DeleteScheduler() [2/2]
| void Engine::SchedulerContainer::DeleteScheduler |
( |
std::type_index | id | ) |
|
Deletes a scheduler identified by the given type index.
- Parameters
-
| id | The type index of the scheduler to be deleted. |
◆ GetScheduler() [1/2]
template<typename TScheduler>
| TScheduler & Engine::SchedulerContainer::GetScheduler |
( |
| ) |
|
|
inline |
Retrieves a scheduler of the specified type.
- Template Parameters
-
| TScheduler | The type of the scheduler to retrieve. |
◆ GetScheduler() [2/2]
Retrieves a scheduler identified by the given type index.
- Parameters
-
| id | The type index of the scheduler to retrieve. |
- Returns
- A shared pointer to the scheduler of the specified type.
◆ ProcessDependencies()
| void Engine::SchedulerContainer::ProcessDependencies |
( |
std::type_index | current, |
|
|
std::queue< std::type_index > & | q, |
|
|
std::map< std::type_index, size_t > & | inDegree ) const |
|
private |
Helper function to process the dependencies of a scheduler during the topological sort. It updates the in-degree of the dependent schedulers and adds them to the queue if their in-degree becomes zero.
- Parameters
-
| current | The type index of the current scheduler being processed. |
| q | The queue used for the topological sort, containing schedulers with zero in-degree. |
| inDegree | A map that keeps track of the in-degree of each scheduler, which is the number of dependencies it has. |
◆ RemoveDependencyAfter()
template<typename TAfter, typename TBefore>
| void Engine::SchedulerContainer::RemoveDependencyAfter |
( |
| ) |
|
Remove a dependency between two schedulers. It will remove the dependency that the first scheduler is after the second one.
- Template Parameters
-
| TAfter | The type of the first scheduler. |
| TBefore | The type of the second scheduler. |
◆ RemoveDependencyBefore()
template<typename TBefore, typename TAfter>
| void Engine::SchedulerContainer::RemoveDependencyBefore |
( |
| ) |
|
Remove a dependency between two schedulers. It will remove the dependency that the first scheduler is before the second one.
- Template Parameters
-
| TBefore | The type of the first scheduler. |
| TAfter | The type of the second scheduler. |
◆ RunSchedulers()
| void Engine::SchedulerContainer::RunSchedulers |
( |
| ) |
|
|
inline |
Runs all schedulers in the container. This function iterates through the ordered list of schedulers and calls the RunSystems method on each scheduler. It ensures that the schedulers are executed in the order defined by their dependencies.
◆ SetErrorPolicyForAllSchedulers()
◆ TopologicalSort()
| void Engine::SchedulerContainer::TopologicalSort |
( |
| ) |
|
|
private |
Apply a topological sort between all schedulers based on their dependencies.
◆ Update()
| void Engine::SchedulerContainer::Update |
( |
| ) |
|
|
private |
Updates the order of schedulers based on their dependencies. This function performs a topological sort on the schedulers to determine the correct execution order. It checks for circular dependencies.
◆ _dependencies
| std::unordered_map<std::type_index, std::unordered_set<std::type_index> > Engine::SchedulerContainer::_dependencies |
|
private |
A map of the dependencies between schedulers. The key is the type index of a scheduler, and the value is a set of type indices of schedulers that depend on the key scheduler.
◆ _dirty
| bool Engine::SchedulerContainer::_dirty = false |
|
private |
A flag indicating whether the order of schedulers needs to be updated.
◆ _orderedSchedulers
A list of the the ordered list of schedulers.
◆ _schedulers
| std::map<std::type_index, std::shared_ptr<Scheduler::AScheduler> > Engine::SchedulerContainer::_schedulers |
|
private |
The documentation for this class was generated from the following files: