1
0

basic threadsafe queue interface

This commit is contained in:
Tycho Bickerstaff 2013-12-21 14:43:32 +00:00
parent c99e841e24
commit 14d2085e35
2 changed files with 34 additions and 0 deletions

30
src/OSSupport/Queue.h Normal file
View File

@ -0,0 +1,30 @@
#pragma once
template<class T>
class cDeleter
{
public:
static void Delete(T) {};
}
template<class T, class D = cDelete>
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;
}
//template classes must be implemented in the header
#include "Queue.inc"

4
src/OSSupport/Queue.inc Normal file
View File

@ -0,0 +1,4 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules