Debian Codegraph @

Source/Scheduler/CTaskHandleLimitedReserveMemoryPoolAllocationManager.cpp

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