| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "CThroughputTestTaskHandleAlgorithm.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Test { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
CThroughputTestTaskHandleAlgorithm::CThroughputTestTaskHandleAlgorithm() { |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
CThroughputTestTaskHandleAlgorithm::~CThroughputTestTaskHandleAlgorithm() { |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
bool CThroughputTestTaskHandleAlgorithm::handleTask(CTaskProcessorContext *processorContext, CTask* task) { |
| 39 |
CTaskHandleMemoryAllocationManager* processorMemoryManager = processorContext->getTaskHandleMemoryAllocationManager(); |
| 40 |
CTaskProcessorCommunicator* processorCommunicator = processorContext->getTaskProcessorCommunicator(); |
| 41 |
|
| 42 |
CThroughputTestTask* testTask = dynamic_cast<CThroughputTestTask*>(task); |
| 43 |
if (testTask) { |
| 44 |
bool complete = false; |
| 45 |
try { |
| 46 |
if (!testTask->hasReachedMaxBranchingDepth()) { |
| 47 |
|
| 48 |
CMemoryAllocationManager* taskMemMan = testTask->getTaskContext(processorContext)->getMemoryAllocationManager(); |
| 49 |
cint64 branchingFactor = testTask->getBranchingFactor(); |
| 50 |
|
| 51 |
cint64 allocCount = 0; |
| 52 |
for (int i = 0; i < allocCount; ++i) { |
| 53 |
cint64* testArray = CObjectAllocator<cint64>::allocateAndConstructArray(taskMemMan,branchingFactor); |
| 54 |
for (int j = 0; j < branchingFactor; ++j) { |
| 55 |
testArray[j] = 0; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
CTask* lastNewTestTask = nullptr; |
| 60 |
|
| 61 |
for (cint64 branchIdx = 0; branchIdx < branchingFactor; ++branchIdx) { |
| 62 |
CThroughputTestTask* newTestTask = CTaskAllocator<CThroughputTestTask>::allocateAndConstructTask(processorMemoryManager); |
| 63 |
newTestTask->initTask(testTask,processorContext); |
| 64 |
lastNewTestTask = newTestTask->setNext(lastNewTestTask); |
| 65 |
} |
| 66 |
|
| 67 |
processorCommunicator->communicateTaskCreation(lastNewTestTask); |
| 68 |
} |
| 69 |
throw 0; |
| 70 |
} catch (const int& x) { |
| 71 |
if (x == 0) { |
| 72 |
complete = true; |
| 73 |
} |
| 74 |
} |
| 75 |
processorCommunicator->communicateTaskComplete(testTask); |
| 76 |
|
| 77 |
} |
| 78 |
return false; |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
}; // end namespace Test |
| 84 |
|
| 85 |
}; // end namespace Konclude |