From 8be3a8f7dc10dbc49dfcdeca572677ef1e00f714 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 23 May 2014 17:18:11 +0100 Subject: Implemented Allocation Pool use by cChunkData --- src/ChunkMap.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index c3deda088..1744c09d0 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -347,7 +347,8 @@ private: class cChunkLayer { public: - cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent); + cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent, + cAllocationPool& a_Pool); ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ @@ -391,6 +392,16 @@ private: int m_LayerZ; cChunkMap * m_Parent; int m_NumChunksLoaded; + + cAllocationPool & m_Pool; + }; + + class cStarvationCallbacks + : public cAllocationPool::cStarvationCallbacks + { + virtual void OnStartingUsingBuffer() {} + virtual void OnStopUsingBuffer() {} + virtual void OnBufferEmpty() {} }; typedef std::list cChunkLayerList; @@ -423,6 +434,8 @@ private: /** The cChunkStay descendants that are currently enabled in this chunkmap */ cChunkStays m_ChunkStays; + cAllocationPool m_Pool; + cChunkPtr GetChunk (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate cChunkPtr GetChunkNoLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Doesn't load, doesn't generate -- cgit v1.2.3 From 061102c77860e7a31b7504ca52bb99e419393fb2 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 17:23:57 +0100 Subject: Added logging --- src/ChunkMap.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 1a3258f15..efe489854 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -403,9 +403,18 @@ private: class cStarvationCallbacks : public cAllocationPool::cStarvationCallbacks { - virtual void OnStartingUsingBuffer() {} - virtual void OnStopUsingBuffer() {} - virtual void OnBufferEmpty() {} + virtual void OnStartingUsingBuffer() + { + LOG("Using backup memory buffer"); + } + virtual void OnStopUsingBuffer() + { + LOG("Stoped using backup memory buffer"); + } + virtual void OnBufferEmpty() + { + LOG("Out of Memory"); + } }; typedef std::list cChunkLayerList; -- cgit v1.2.3 From 0310a50192fcbd4a9e5ec03c98a0d7f33457df54 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 18:43:36 +0100 Subject: fixed spaces --- src/ChunkMap.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index efe489854..071921f92 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -352,7 +352,7 @@ private: { public: cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent, - cAllocationPool& a_Pool); + cAllocationPool& a_Pool); ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ @@ -397,11 +397,11 @@ private: cChunkMap * m_Parent; int m_NumChunksLoaded; - cAllocationPool & m_Pool; + cAllocationPool & m_Pool; }; class cStarvationCallbacks - : public cAllocationPool::cStarvationCallbacks + : public cAllocationPool::cStarvationCallbacks { virtual void OnStartingUsingBuffer() { @@ -447,7 +447,7 @@ private: /** The cChunkStay descendants that are currently enabled in this chunkmap */ cChunkStays m_ChunkStays; - cAllocationPool m_Pool; + cAllocationPool m_Pool; cChunkPtr GetChunk (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate -- cgit v1.2.3 From 6b99e556462fdbdf6a265c014fb03f070b0f1b25 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:05:02 +0100 Subject: fixed spaces --- src/ChunkMap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 071921f92..08156e7e6 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -352,7 +352,7 @@ private: { public: cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent, - cAllocationPool& a_Pool); + cAllocationPool & a_Pool); ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ -- cgit v1.2.3 From 94c48febd2f596648fc2616a8a577316a219b581 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:46:34 +0100 Subject: Added generic Allocation Pool Interface --- src/ChunkMap.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 08156e7e6..c1dc743e5 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -352,7 +352,7 @@ private: { public: cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent, - cAllocationPool & a_Pool); + cAllocationPool & a_Pool); ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ @@ -397,11 +397,11 @@ private: cChunkMap * m_Parent; int m_NumChunksLoaded; - cAllocationPool & m_Pool; + cAllocationPool & m_Pool; }; class cStarvationCallbacks - : public cAllocationPool::cStarvationCallbacks + : public cAllocationPool::cStarvationCallbacks { virtual void OnStartingUsingBuffer() { @@ -447,7 +447,7 @@ private: /** The cChunkStay descendants that are currently enabled in this chunkmap */ cChunkStays m_ChunkStays; - cAllocationPool m_Pool; + std::auto_ptr> m_Pool; cChunkPtr GetChunk (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading / generating if not valid cChunkPtr GetChunkNoGen (int a_ChunkX, int a_ChunkY, int a_ChunkZ); // Also queues the chunk for loading if not valid; doesn't generate -- cgit v1.2.3 From f97116141f464d4e27515197eec7d42f9d2ba772 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 19:56:01 +0100 Subject: Reformated ChunkMap.h --- src/ChunkMap.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index c1dc743e5..0d6f1f80a 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -351,8 +351,11 @@ private: class cChunkLayer { public: - cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent, - cAllocationPool & a_Pool); + cChunkLayer( + int a_LayerX, int a_LayerZ, + cChunkMap * a_Parent, + cAllocationPool & a_Pool + ); ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ -- cgit v1.2.3 From 8a2aa6cb169563c7df752821e032b1cab1bac5d1 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 14 Jun 2014 20:24:52 +0100 Subject: Changed names of callbacks --- src/ChunkMap.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 0d6f1f80a..fd319fbc9 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -406,15 +406,15 @@ private: class cStarvationCallbacks : public cAllocationPool::cStarvationCallbacks { - virtual void OnStartingUsingBuffer() + virtual void OnStartUsingReserve() { LOG("Using backup memory buffer"); } - virtual void OnStopUsingBuffer() + virtual void OnEndUsingReserve() { LOG("Stoped using backup memory buffer"); } - virtual void OnBufferEmpty() + virtual void OnOutOfReserve() { LOG("Out of Memory"); } -- cgit v1.2.3 From 1e57161ecc09ca9aa009b5c4795113aae95d89ea Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 14:12:10 +0100 Subject: Added override --- src/ChunkMap.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ChunkMap.h') diff --git a/src/ChunkMap.h b/src/ChunkMap.h index fd319fbc9..5aad0dd2a 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -406,15 +406,15 @@ private: class cStarvationCallbacks : public cAllocationPool::cStarvationCallbacks { - virtual void OnStartUsingReserve() + virtual void OnStartUsingReserve() override { LOG("Using backup memory buffer"); } - virtual void OnEndUsingReserve() + virtual void OnEndUsingReserve() override { LOG("Stoped using backup memory buffer"); } - virtual void OnOutOfReserve() + virtual void OnOutOfReserve() override { LOG("Out of Memory"); } -- cgit v1.2.3