logic: Fixed bugs in TaskParse scheduling

* Added TaskParse as base for TaskParseCxx and TaskParseJava
* Fixed increment and decrement of indexer_count on blackboard not atomic
* Fixed TaskInjectStorage finished before TaskParse started
* Fixed project not cleared when refreshing on now empty project
* Fixed TaskInjectStorage overheating when nothing to do
This commit is contained in:
Eberhard Graether
2016-10-20 23:02:54 +02:00
parent a388932864
commit 06c7a4e159
12 changed files with 147 additions and 128 deletions
+25 -1
View File
@@ -1,5 +1,8 @@
#include "data/TaskInjectStorage.h"
#include <chrono>
#include <thread>
#include "data/Storage.h"
#include "data/StorageProvider.h"
#include "utility/scheduling/Blackboard.h"
@@ -10,11 +13,26 @@ TaskInjectStorage::TaskInjectStorage(
)
: m_storageProvider(storageProvider)
, m_target(target)
, m_hasInjected(false)
{
}
void TaskInjectStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
{
while (!m_hasInjected)
{
int indexerCount = 0;
if (blackboard->get("indexer_count", indexerCount))
{
if (indexerCount > 0 || m_storageProvider->getStorageCount() > 0)
{
break;
}
}
const int SLEEP_TIME_MS = 25;
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
}
}
Task::TaskState TaskInjectStorage::doUpdate(std::shared_ptr<Blackboard> blackboard)
@@ -25,14 +43,20 @@ Task::TaskState TaskInjectStorage::doUpdate(std::shared_ptr<Blackboard> blackboa
if (source)
{
m_target->inject(source.get());
m_hasInjected = true;
return STATE_SUCCESS;
}
}
else
{
const int SLEEP_TIME_MS = 25;
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
}
int indexerCount = 0;
if (blackboard->get("indexer_count", indexerCount))
{
if (indexerCount > 0)
if (indexerCount > 0 || m_storageProvider->getStorageCount() > 0)
{
return STATE_SUCCESS;
}