Skip to content

Commit

Permalink
Don't use C++ 17 features/syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab authored and Al2Klimov committed Jan 22, 2025
1 parent 892fcd2 commit 72d1c53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/base/dependencygraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ DependencyGraph::DependencyMap DependencyGraph::m_Dependencies;
void DependencyGraph::AddDependency(ConfigObject* child, ConfigObject* parent)
{
std::unique_lock<std::mutex> lock(m_Mutex);
if (auto [it, inserted] = m_Dependencies.insert(Edge(parent, child)); !inserted) {
m_Dependencies.modify(it, [](Edge& e) { e.count++; });
auto pair = m_Dependencies.insert(Edge(parent, child));
if (!pair.second) {
m_Dependencies.modify(pair.first, [](Edge& e) { e.count++; });
}
}

void DependencyGraph::RemoveDependency(ConfigObject* child, ConfigObject* parent)
{
std::unique_lock<std::mutex> lock(m_Mutex);

if (auto it(m_Dependencies.find(Edge(parent, child))); it != m_Dependencies.end()) {
auto it(m_Dependencies.find(Edge(parent, child)));
if (it != m_Dependencies.end()) {
if (it->count > 1) {
// Remove a duplicate edge from child to node, i.e. decrement the corresponding counter.
m_Dependencies.modify(it, [](Edge& e) { e.count--; });
Expand Down
3 changes: 2 additions & 1 deletion lib/remote/apilistener-configsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ void ApiListener::SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient

std::unordered_set<ConfigObject*> syncedObjects;
for (const Type::Ptr& type : Type::GetAllTypes()) {
if (auto *ctype = dynamic_cast<ConfigType *>(type.get())) {
auto *ctype = dynamic_cast<ConfigType *>(type.get());
if (ctype) {
for (const auto& object : ctype->GetObjects()) {
// All objects must be synced sorted by their dependency graph.
// Otherwise, downtimes/comments etc. might get synced before their respective Checkables, which will
Expand Down

0 comments on commit 72d1c53

Please sign in to comment.