mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-06-20 14:33:15 -04:00
[EGD-5027] Services synchronization introduced
Dependencies between services are now supported.
This commit is contained in:
committed by
Piotr Tanski
parent
e1400aee90
commit
65119cb495
32
module-sys/SystemManager/DependencyGraph.cpp
Normal file
32
module-sys/SystemManager/DependencyGraph.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
||||
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
||||
|
||||
#include "DependencyGraph.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
namespace sys
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
Nodes nodesFrom(const std::vector<std::unique_ptr<BaseServiceCreator>> &services)
|
||||
{
|
||||
Nodes nodes;
|
||||
nodes.reserve(services.size());
|
||||
std::transform(services.begin(), services.end(), std::back_inserter(nodes), [](const auto &service) {
|
||||
return std::ref(*service);
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
} // namespace graph
|
||||
|
||||
DependencyGraph::DependencyGraph(graph::Nodes nodes, std::unique_ptr<DependencySortingStrategy> &&strategy)
|
||||
: nodes{std::move(nodes)}, strategy{std::move(strategy)}
|
||||
{}
|
||||
|
||||
auto DependencyGraph::sort() const -> graph::Nodes
|
||||
{
|
||||
return strategy->sort(nodes);
|
||||
}
|
||||
} // namespace sys
|
||||
Reference in New Issue
Block a user