Files
Sourcetrail/src/lib/data/TaskInjectStorage.cpp
T
mlangkabel 951256c07b logic: reduced waiting time when interrupting indexer processes
* made multiprocess AST traversal interruptible again
* removed const variables that define sleep times for threads
2018-09-21 17:19:03 +02:00

51 lines
1016 B
C++

#include "TaskInjectStorage.h"
#include <chrono>
#include <thread>
#include "Storage.h"
#include "StorageProvider.h"
TaskInjectStorage::TaskInjectStorage(
std::shared_ptr<StorageProvider> storageProvider,
std::weak_ptr<Storage> target
)
: m_storageProvider(storageProvider)
, m_target(target)
{
}
void TaskInjectStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
{
}
Task::TaskState TaskInjectStorage::doUpdate(std::shared_ptr<Blackboard> blackboard)
{
if (m_storageProvider->getStorageCount() > 0)
{
std::shared_ptr<IntermediateStorage> source = m_storageProvider->consumeLargestStorage();
if (source)
{
if (std::shared_ptr<Storage> target = m_target.lock())
{
target->inject(source.get());
return STATE_SUCCESS;
}
}
}
else
{
std::this_thread::sleep_for(std::chrono::milliseconds(25));
}
return STATE_FAILURE;
}
void TaskInjectStorage::doExit(std::shared_ptr<Blackboard> blackboard)
{
}
void TaskInjectStorage::doReset(std::shared_ptr<Blackboard> blackboard)
{
}