-
Notifications
You must be signed in to change notification settings - Fork 6
/
pxQueueBuffer.cpp
70 lines (52 loc) · 1.11 KB
/
pxQueueBuffer.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
61
62
63
64
65
66
67
68
69
70
#include "StdAfx.h"
#include "pxQueueBuffer.h"
CPxQueueBuffer::CPxQueueBuffer(void)
{
::InitializeCriticalSection(&m_csBufferList);
}
CPxQueueBuffer::~CPxQueueBuffer(void)
{
::DeleteCriticalSection(&m_csBufferList);
}
void CPxQueueBuffer::Push(SPxBuffer *in_psBuffer)
{
::EnterCriticalSection(&m_csBufferList);
if (NULL == in_psBuffer)
{
::LeaveCriticalSection(&m_csBufferList);
return ;
}
m_qBufferList.push(*in_psBuffer);
::LeaveCriticalSection(&m_csBufferList);
}
SPxBuffer *CPxQueueBuffer::Front()
{
::EnterCriticalSection(&m_csBufferList);
if (m_qBufferList.size() == 0)
{
::LeaveCriticalSection(&m_csBufferList);
return NULL;
}
SPxBuffer *psPxBuffer = &m_qBufferList.front();
::LeaveCriticalSection(&m_csBufferList);
return psPxBuffer;
}
void CPxQueueBuffer::Pop()
{
::EnterCriticalSection(&m_csBufferList);
if (0 == m_qBufferList.size())
{
::LeaveCriticalSection(&m_csBufferList);
return ;
}
m_qBufferList.pop();
::LeaveCriticalSection(&m_csBufferList);
}
int CPxQueueBuffer::Size()
{
return m_qBufferList.size();
}
bool CPxQueueBuffer::IsEmpty()
{
return m_qBufferList.empty();
}