69 lines
1.5 KiB
C++
69 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2025 Fraunhofer IESE. All rights reserved.
|
|
*
|
|
* Authors:
|
|
* Iron Prando da Silva
|
|
*/
|
|
|
|
#include "poolcontroller.h"
|
|
#include <algorithm>
|
|
|
|
PoolController::PoolController(const uint poolSize, const std::vector<PoolEntry>& dependencies) :
|
|
mDependencies(mAuxSortInput(dependencies))
|
|
{
|
|
mPoolSize = poolSize;
|
|
}
|
|
|
|
void PoolController::clear()
|
|
{
|
|
mPool.clear();
|
|
mCount = 0;
|
|
}
|
|
|
|
void PoolController::push(DBDependencyEntry dep)
|
|
{
|
|
mPool.push_back(dep);
|
|
mCount++;
|
|
}
|
|
|
|
void PoolController::increment()
|
|
{
|
|
mCount++;
|
|
}
|
|
|
|
void PoolController::merge(std::vector<DBDependencyEntry>& depEntries)
|
|
{
|
|
if (mCount >= mPoolSize)
|
|
{
|
|
depEntries.insert(depEntries.end(), mPool.begin(), mPool.end());
|
|
}
|
|
}
|
|
|
|
uint PoolController::getBusyTime(const StringMapper& phaseName)
|
|
{
|
|
PoolEntry v{phaseName, 0};
|
|
|
|
auto entryIt = std::lower_bound(mDependencies.begin(),
|
|
mDependencies.end(),
|
|
v,
|
|
[](const PoolEntry& e1, const PoolEntry& e2)
|
|
{ return e1.first < e2.first; });
|
|
|
|
if (entryIt->first == phaseName)
|
|
{
|
|
return entryIt->second;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
std::vector<PoolEntry> PoolController::mAuxSortInput(std::vector<PoolEntry> vec)
|
|
{
|
|
std::sort(vec.begin(),
|
|
vec.end(),
|
|
[](const PoolEntry& e1, const PoolEntry& e2) { return e1.first < e2.first; });
|
|
|
|
return vec;
|
|
} |