summaryrefslogtreecommitdiffstats
path: root/src/WorldStorage/WorldStorage.h
diff options
context:
space:
mode:
authorTycho Bickerstaff <work.tycho@gmail.com>2013-12-31 16:48:57 +0100
committerTycho Bickerstaff <work.tycho@gmail.com>2013-12-31 16:48:57 +0100
commitf3736b1eb7bf698518cdb853ee29ee96b9c24a52 (patch)
treeb5a9c4f14e44bc0fd9b88c9d30bc4036c06eff5e /src/WorldStorage/WorldStorage.h
parentadded link dependency between WorldStorage and OSSupport (diff)
downloadcuberite-f3736b1eb7bf698518cdb853ee29ee96b9c24a52.tar
cuberite-f3736b1eb7bf698518cdb853ee29ee96b9c24a52.tar.gz
cuberite-f3736b1eb7bf698518cdb853ee29ee96b9c24a52.tar.bz2
cuberite-f3736b1eb7bf698518cdb853ee29ee96b9c24a52.tar.lz
cuberite-f3736b1eb7bf698518cdb853ee29ee96b9c24a52.tar.xz
cuberite-f3736b1eb7bf698518cdb853ee29ee96b9c24a52.tar.zst
cuberite-f3736b1eb7bf698518cdb853ee29ee96b9c24a52.zip
Diffstat (limited to 'src/WorldStorage/WorldStorage.h')
-rw-r--r--src/WorldStorage/WorldStorage.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index 007d37571..c3eb96ce8 100644
--- a/src/WorldStorage/WorldStorage.h
+++ b/src/WorldStorage/WorldStorage.h
@@ -16,6 +16,7 @@
#include "../ChunkDef.h"
#include "../OSSupport/IsThread.h"
+#include "../OSSupport/Queue.h"
@@ -24,6 +25,8 @@
// fwd:
class cWorld;
+typedef cQueue<cChunkCoords> cChunkCoordsQueue;
+
@@ -78,8 +81,8 @@ public:
void WaitForFinish(void);
void WaitForQueuesEmpty(void);
- int GetLoadQueueLength(void);
- int GetSaveQueueLength(void);
+ size_t GetLoadQueueLength(void);
+ size_t GetSaveQueueLength(void);
protected:
@@ -91,9 +94,24 @@ protected:
bool m_Generate; // If true, the chunk will be generated if it cannot be loaded
sChunkLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate) : m_ChunkX(a_ChunkX), m_ChunkY(a_ChunkY), m_ChunkZ(a_ChunkZ), m_Generate(a_Generate) {}
+
+ bool operator==(const sChunkLoad other) const
+ {
+ return this->m_ChunkX == other.m_ChunkX &&
+ this->m_ChunkY == other.m_ChunkY &&
+ this->m_ChunkZ == other.m_ChunkZ;
+ }
} ;
-
- typedef std::list<sChunkLoad> sChunkLoadQueue;
+
+ struct FuncTable {
+ static void Delete(sChunkLoad) {};
+ static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new)
+ {
+ a_orig.m_Generate |= a_new.m_Generate;
+ };
+ };
+
+ typedef cQueue<sChunkLoad,FuncTable> sChunkLoadQueue;
cWorld * m_World;
AString m_StorageSchemaName;
@@ -101,7 +119,7 @@ protected:
// Both queues are locked by the same CS
cCriticalSection m_CSQueues;
sChunkLoadQueue m_LoadQueue;
- cChunkCoordsList m_SaveQueue;
+ cChunkCoordsQueue m_SaveQueue;
cEvent m_Event; // Set when there's any addition to the queues
cEvent m_evtRemoved; // Set when an item has been removed from the queue, either by the worker thread or the Unqueue methods