summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTycho Bickerstaff <work.tycho@gmail.com>2013-12-22 16:41:01 +0100
committerTycho Bickerstaff <work.tycho@gmail.com>2013-12-22 16:41:01 +0100
commita71299c46b7b53a5f9f11ea2851f8e5b66d2d912 (patch)
treefc2d950d5a7362aaaec0a0ea3d4cac16c36c7cbd /src
parentfixes for mac os x (diff)
downloadcuberite-a71299c46b7b53a5f9f11ea2851f8e5b66d2d912.tar
cuberite-a71299c46b7b53a5f9f11ea2851f8e5b66d2d912.tar.gz
cuberite-a71299c46b7b53a5f9f11ea2851f8e5b66d2d912.tar.bz2
cuberite-a71299c46b7b53a5f9f11ea2851f8e5b66d2d912.tar.lz
cuberite-a71299c46b7b53a5f9f11ea2851f8e5b66d2d912.tar.xz
cuberite-a71299c46b7b53a5f9f11ea2851f8e5b66d2d912.tar.zst
cuberite-a71299c46b7b53a5f9f11ea2851f8e5b66d2d912.zip
Diffstat (limited to 'src')
-rw-r--r--src/OSSupport/Queue.h31
-rw-r--r--src/WorldStorage/WorldStorage.h3
2 files changed, 33 insertions, 1 deletions
diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h
new file mode 100644
index 000000000..4571272b3
--- /dev/null
+++ b/src/OSSupport/Queue.h
@@ -0,0 +1,31 @@
+#pragma once
+
+template<class T>
+class cDeleter
+{
+ public:
+ static void Delete(T) {};
+};
+
+template<class T, class D = cDeleter<T>>
+class cQueue
+{
+public:
+ cQueue(int warnsize);
+ cQueue(cQueue<T>& queue);
+ ~cQueue();
+
+ void EnqueueItem(T item);
+ bool TryDequeueItem(T& item);
+ T DequeueItem();
+ void BlockTillEmpty(cEvent CancelationEvent);
+ void Clear();
+ int Size();
+
+private:
+ int warnsize;
+ std::list<T> contents;
+};
+
+//template classes must be implemented in the header
+#include "Queue.inc"
diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h
index 007d37571..106842a22 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"
@@ -93,7 +94,7 @@ protected:
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) {}
} ;
- typedef std::list<sChunkLoad> sChunkLoadQueue;
+ typedef cQueue<sChunkLoad> sChunkLoadQueue;
cWorld * m_World;
AString m_StorageSchemaName;