* replaced parser arguments by project specific IndexerCommands that know everything the indexer needs to know to do its job * added different language and project specific indexers that know how to handle a certain kind of indexer command * refactored FileManager and FileRegister to have less overhead * removed no-rtti restriction for clang files in lib cxx * uncommented deprecated interprocess code. fortune cookie message = Happiness will bring you good luck.
73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
#include "data/StorageProvider.h"
|
|
|
|
#include "utility/logging/logging.h"
|
|
|
|
int StorageProvider::getStorageCount() const
|
|
{
|
|
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
|
return m_storages.size();
|
|
}
|
|
|
|
void StorageProvider::insert(std::shared_ptr<IntermediateStorage> storage)
|
|
{
|
|
const std::size_t storageSize = storage->getSourceLocationCount();
|
|
std::list<std::shared_ptr<IntermediateStorage>>::iterator it;
|
|
|
|
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
|
for (it = m_storages.begin(); it != m_storages.end(); it++)
|
|
{
|
|
if ((*it)->getSourceLocationCount() < storageSize)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
m_storages.insert(it, storage);
|
|
}
|
|
|
|
std::shared_ptr<IntermediateStorage> StorageProvider::consumeSecondLargestStorage()
|
|
{
|
|
std::shared_ptr<IntermediateStorage> ret;
|
|
{
|
|
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
|
if (m_storages.size() > 1)
|
|
{
|
|
std::list<std::shared_ptr<IntermediateStorage>>::iterator it = m_storages.begin();
|
|
it++;
|
|
ret = *it;
|
|
m_storages.erase(it);
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
std::shared_ptr<IntermediateStorage> StorageProvider::consumeLargestStorage()
|
|
{
|
|
std::shared_ptr<IntermediateStorage> ret;
|
|
{
|
|
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
|
if (!m_storages.empty())
|
|
{
|
|
ret = m_storages.front();
|
|
m_storages.pop_front();
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
void StorageProvider::logCurrentState() const
|
|
{
|
|
std::string logString = "Storages waiting for injection:";
|
|
{
|
|
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
|
for (std::shared_ptr<IntermediateStorage> storage: m_storages)
|
|
{
|
|
logString += " " + std::to_string(storage->getSourceLocationCount()) + ";";
|
|
}
|
|
}
|
|
LOG_INFO(logString);
|
|
}
|
|
|
|
|
|
|