| 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 "CTaskHandleMemoryPoolAllocationManager.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Scheduler { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
CTaskHandleMemoryPoolAllocationManager::CTaskHandleMemoryPoolAllocationManager(CConsiderateMemoryPoolProvider* memoryPoolProvider) : CMemoryPoolAllocationManager(memoryPoolProvider) { |
| 31 |
mConsideratedMemPoolProvider = memoryPoolProvider; |
| 32 |
} |
| 33 |
|
| 34 |
CTaskHandleMemoryPoolAllocationManager::~CTaskHandleMemoryPoolAllocationManager() { |
| 35 |
} |
| 36 |
|
| 37 |
void* CTaskHandleMemoryPoolAllocationManager::allocate(size_t size) { |
| 38 |
return CMemoryPoolAllocationManager::allocate(size); |
| 39 |
} |
| 40 |
|
| 41 |
CMemoryAllocationManager* CTaskHandleMemoryPoolAllocationManager::release(void* address) { |
| 42 |
return CMemoryPoolAllocationManager::release(address); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
void* CTaskHandleMemoryPoolAllocationManager::allocateAligned(size_t size, int alignment) { |
| 47 |
return CMemoryPoolAllocationManager::allocateAligned(size,alignment); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
CMemoryTemporaryAllocationManager* CTaskHandleMemoryPoolAllocationManager::releaseAllMemory() { |
| 52 |
return CMemoryPoolAllocationManager::releaseAllMemory(); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
CMemoryPool* CTaskHandleMemoryPoolAllocationManager::acqireTemporaryMemoryPool(size_t size) { |
| 57 |
return CMemoryPoolAllocationManager::acqireTemporaryMemoryPool(size); |
| 58 |
} |
| 59 |
|
| 60 |
CMemoryTemporaryAllocationManager* CTaskHandleMemoryPoolAllocationManager::releaseTemporaryMemoryPool(CMemoryPool* memoryPool) { |
| 61 |
return CMemoryPoolAllocationManager::releaseTemporaryMemoryPool(memoryPool); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
cint64 CTaskHandleMemoryPoolAllocationManager::getOptimizedMoreAllocationSize(cint64 size) { |
| 66 |
return CMemoryPoolAllocationManager::getOptimizedMoreAllocationSize(size); |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
CMemoryTemporaryAllocationManager* CTaskHandleMemoryPoolAllocationManager::releaseMemoryPoolContainer(CMemoryPoolContainer* memoryPoolContainer) { |
| 71 |
return CMemoryPoolAllocationManager::releaseMemoryPoolContainer(memoryPoolContainer); |
| 72 |
} |
| 73 |
|
| 74 |
CMemoryPoolProvider* CTaskHandleMemoryPoolAllocationManager::releaseMemoryPool(CMemoryPool* memoryPool) { |
| 75 |
return CMemoryPoolAllocationManager::releaseMemoryPool(memoryPool); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
CMemoryPool* CTaskHandleMemoryPoolAllocationManager::acquireMemoryPool(cint64 minPoolSize) { |
| 80 |
return CMemoryPoolAllocationManager::acquireMemoryPool(minPoolSize); |
| 81 |
} |
| 82 |
|
| 83 |
CMemoryPool* CTaskHandleMemoryPoolAllocationManager::acquireMemoryPoolConsiderated(cint64 minPoolSize) { |
| 84 |
CMemoryPool* tmpMemoryPool = nullptr; |
| 85 |
if (mFreeMemoryPoolList) { |
| 86 |
if (mFreeMemoryPoolList->getMemoryBlockSize() >= minPoolSize) { |
| 87 |
tmpMemoryPool = mFreeMemoryPoolList; |
| 88 |
mFreeMemoryPoolList = mFreeMemoryPoolList->getNextMemoryPool(); |
| 89 |
--mFreeMemoryPoolCount; |
| 90 |
} |
| 91 |
} |
| 92 |
if (!tmpMemoryPool) { |
| 93 |
tmpMemoryPool = mConsideratedMemPoolProvider->acquireMemoryPoolConsiderated(minPoolSize); |
| 94 |
} |
| 95 |
if (tmpMemoryPool) { |
| 96 |
++mStatMemToUsingCount; |
| 97 |
tmpMemoryPool->clearNext(); |
| 98 |
} |
| 99 |
return tmpMemoryPool; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
}; // end namespace Scheduler |
| 106 |
|
| 107 |
}; // end namespace Konclude |