basic threadsafe queue interface
This commit is contained in:
parent
c99e841e24
commit
14d2085e35
30
src/OSSupport/Queue.h
Normal file
30
src/OSSupport/Queue.h
Normal 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
4
src/OSSupport/Queue.inc
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user