diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-21 23:14:23 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-06-21 23:14:23 +0200 |
commit | 7615ed90c020b88db52b0b094f00cd028e326b5a (patch) | |
tree | ca7f647e77195a6346a2333f3d9fe5292cd2ed40 /src/ChunkMap.h | |
parent | Fixed invalid iterators (diff) | |
parent | Merge branch 'master' of https://github.com/mc-server/MCServer (diff) | |
download | cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.gz cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.bz2 cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.lz cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.xz cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.tar.zst cuberite-7615ed90c020b88db52b0b094f00cd028e326b5a.zip |
Diffstat (limited to 'src/ChunkMap.h')
-rw-r--r-- | src/ChunkMap.h | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/ChunkMap.h b/src/ChunkMap.h index 7e85bb6f1..3ee0bab3c 100644 --- a/src/ChunkMap.h +++ b/src/ChunkMap.h @@ -35,8 +35,8 @@ class cBlockArea; class cMobCensus; class cMobSpawner; -typedef std::list<cClientHandle *> cClientHandleList; -typedef cChunk * cChunkPtr; +typedef std::list<cClientHandle *> cClientHandleList; +typedef cChunk * cChunkPtr; typedef cItemCallback<cEntity> cEntityCallback; typedef cItemCallback<cBlockEntity> cBlockEntityCallback; typedef cItemCallback<cChestEntity> cChestCallback; @@ -351,7 +351,11 @@ 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<cChunkData::sChunkSection> & a_Pool + ); ~cChunkLayer(); /** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */ @@ -395,6 +399,25 @@ private: int m_LayerZ; cChunkMap * m_Parent; int m_NumChunksLoaded; + + cAllocationPool<cChunkData::sChunkSection> & m_Pool; + }; + + class cStarvationCallbacks + : public cAllocationPool<cChunkData::sChunkSection>::cStarvationCallbacks + { + virtual void OnStartUsingReserve() override + { + LOG("Using backup memory buffer"); + } + virtual void OnEndUsingReserve() override + { + LOG("Stoped using backup memory buffer"); + } + virtual void OnOutOfReserve() override + { + LOG("Out of Memory"); + } }; typedef std::list<cChunkLayer *> cChunkLayerList; @@ -427,6 +450,8 @@ private: /** The cChunkStay descendants that are currently enabled in this chunkmap */ cChunkStays m_ChunkStays; + std::auto_ptr<cAllocationPool<cChunkData::sChunkSection> > 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 |