summaryrefslogtreecommitdiffstats
path: root/src/AllocationPool.h
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:45:45 +0100
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-02-05 22:50:18 +0100
commitca6ef58b1ee8521e4b940ee4883dee714960e413 (patch)
tree8532add455224b07c07a759e3d906f50c0695888 /src/AllocationPool.h
parentMerge pull request #2972 from marvinkopf/PlayerAutoComplete (diff)
downloadcuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.gz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.bz2
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.lz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.xz
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.zst
cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.zip
Diffstat (limited to 'src/AllocationPool.h')
-rw-r--r--src/AllocationPool.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/AllocationPool.h b/src/AllocationPool.h
index 4815ab414..799930708 100644
--- a/src/AllocationPool.h
+++ b/src/AllocationPool.h
@@ -15,23 +15,23 @@ public:
{
public:
virtual ~cStarvationCallbacks() {}
-
+
/** Is called when the reserve buffer starts to be used */
virtual void OnStartUsingReserve() = 0;
-
+
/** Is called once the reserve buffer has returned to normal size */
virtual void OnEndUsingReserve() = 0;
-
+
/** Is called when the allocation pool is unable to allocate memory. Will be repeatedly
called if it does not free sufficient memory */
virtual void OnOutOfReserve() = 0;
};
-
+
virtual ~cAllocationPool() {}
-
+
/** Allocates a pointer to T */
virtual T * Allocate() = 0;
-
+
/** Frees the pointer passed in a_ptr, invalidating it */
virtual void Free(T * a_ptr) = 0;
};
@@ -47,7 +47,7 @@ class cListAllocationPool:
public cAllocationPool<T>
{
public:
-
+
cListAllocationPool(std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> a_Callbacks):
m_Callbacks(std::move(a_Callbacks))
{
@@ -62,7 +62,7 @@ public:
m_FreeList.push_front(space);
}
}
-
+
virtual ~cListAllocationPool()
{
@@ -72,7 +72,7 @@ public:
m_FreeList.pop_front();
}
}
-
+
virtual T * Allocate() override
{
@@ -115,7 +115,7 @@ public:
m_Callbacks->OnEndUsingReserve();
}
}
-
+
private:
std::list<void *> m_FreeList;
std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> m_Callbacks;