39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
|
|
#ifndef __GCircleQueue_H__
|
|||
|
|
#define __GCircleQueue_H__
|
|||
|
|
|
|||
|
|
#include <QMutex>
|
|||
|
|
#include <QMutexLocker>
|
|||
|
|
#include <QWaitCondition>
|
|||
|
|
|
|||
|
|
#include <Windows.h>
|
|||
|
|
|
|||
|
|
const int DEFAULT_QUEUE_SIZE = 16; //默认队列长度
|
|||
|
|
|
|||
|
|
class GCycleQueue
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
GCycleQueue();
|
|||
|
|
virtual ~GCycleQueue();
|
|||
|
|
bool InitQueue(int nFrameSize, int nQueueSize = DEFAULT_QUEUE_SIZE);
|
|||
|
|
bool PushBack(unsigned char* pFrameData, int nFrameSize, int& nRes);
|
|||
|
|
bool GetFront(unsigned char* pFrameData, int& nFrameSize);
|
|||
|
|
unsigned char* GetFrontPoint();
|
|||
|
|
bool GetBack(unsigned char* pFrameData, int& nFrameSize);
|
|||
|
|
bool IsEmpty();
|
|||
|
|
void Clear();
|
|||
|
|
int Size();
|
|||
|
|
protected:
|
|||
|
|
void DestroyQueue();
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
const int m_nFrameSize;
|
|||
|
|
int m_nQueueSize;
|
|||
|
|
unsigned char* m_ptrFrameQueue;
|
|||
|
|
// unsigned char (*m_ptrFrameQueue)[MAX_FRAME_SIZE];
|
|||
|
|
int m_nFront;
|
|||
|
|
int m_nTail;
|
|||
|
|
QMutex m_mutex;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
#endif // !__GCircleQueue_H__
|