-
Notifications
You must be signed in to change notification settings - Fork 3
/
ReaderQ.cpp
60 lines (50 loc) · 949 Bytes
/
ReaderQ.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <windows.h>
#include "ReaderQ.h"
#include "WriterQ.h"
#include "general.h"
CReaderQ::CReaderQ(void)
{
pWriterQ = NULL;
}
CReaderQ::~CReaderQ(void)
{
}
void CReaderQ::Connect(CWriterQ* param)
{
pWriterQ = param;
readIndex = 0;
}
uint32 CReaderQ::GetFilledSize(void)
{
uint32 writeIndex;
uint32 queueSize;
if(pWriterQ)
{
writeIndex = pWriterQ->GetCurIndex();
queueSize = pWriterQ->GetQueueSize();
if(writeIndex >= readIndex )
return writeIndex - readIndex;
return queueSize - readIndex + writeIndex;
}
return 0;
}
uint8 CReaderQ::GetQuantumSize(void)
{
if(pWriterQ)
return pWriterQ->GetQuantumSize();
return 0;
}
void CReaderQ::EmptyQueue(void)
{
if(pWriterQ)
readIndex = pWriterQ->GetCurIndex();
}
void CReaderQ::RemoveFromQueue(uint8* buffer,uint32 size)
{
if(pWriterQ)
{
pWriterQ->RemoveFromQueue(buffer,readIndex,size);
readIndex += size ;
readIndex %= pWriterQ->GetQueueSize() ;
}
}