-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathframe_netqueue.cpp
232 lines (190 loc) · 3.99 KB
/
frame_netqueue.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
* frame_netqueue.cpp
*
* Created on: 2012-11-1
* Author: jimm
*/
#include "frame_errordef.h"
#include "frame_baseconfig.h"
#include "frame_netqueue.h"
FRAME_NAMESPACE_BEGIN
CFrameNetQueue::CFrameNetQueue()
{
}
CFrameNetQueue::~CFrameNetQueue()
{
}
size_t CFrameNetQueue::GetSize()
{
return m_stRecvSSQueue.size() + m_stSendSSQueue.size() +
m_stRecvCSQueue.size() + m_stSendCSQueue.size();
}
const char* CFrameNetQueue::GetName()
{
return LOGICQUEUE_DATACENTER;
}
//初始化CS队列
int32_t CFrameNetQueue::Initialize()
{
return S_OK;
}
//恢复CS队列
int32_t CFrameNetQueue::Resume()
{
return S_OK;
}
//注销CS队列
int32_t CFrameNetQueue::Uninitialize()
{
return S_OK;
}
//从接收队列尾部追加一条消息
int32_t CFrameNetQueue::PushRecvSSQueue(NetPacket *pNetPacket)
{
if(pNetPacket == NULL)
{
return E_NULLPOINTER;
}
MUTEX_GUARD(RecvSSLock, m_stRecvSSLock);
m_stRecvSSQueue.push_back(pNetPacket);
return S_OK;
}
//从接收队列头部读取一条消息
int32_t CFrameNetQueue::PopRecvSSQueue(NetPacket *&pNetPacket)
{
MUTEX_GUARD(RecvSSLock, m_stRecvSSLock);
if(m_stRecvSSQueue.size() > 0)
{
pNetPacket = m_stRecvSSQueue.front();
m_stRecvSSQueue.pop_front();
}
else
{
pNetPacket = NULL;
}
return S_OK;
}
//判断接收队列是否已满
bool CFrameNetQueue::IsRecvSSQueueFull()
{
//MUTEX_GUARD(SSLock, m_stSSLock);
return false;
}
//判读接收队列是否为空
bool CFrameNetQueue::IsRecvSSQueueEmpty()
{
MUTEX_GUARD(RecvSSLock, m_stRecvSSLock);
return m_stRecvSSQueue.empty();
}
//从发送队列尾部追加一条消息
int32_t CFrameNetQueue::PushSendSSQueue(NetPacket *pNetPacket)
{
if(pNetPacket == NULL)
{
return E_NULLPOINTER;
}
MUTEX_GUARD(SendSSLock, m_stSendSSLock);
m_stSendSSQueue.push_back(pNetPacket);
return S_OK;
}
//从发送队列头部读取一条消息
int32_t CFrameNetQueue::PopSendSSQueue(NetPacket *&pNetPacket)
{
MUTEX_GUARD(SendSSLock, m_stSendSSLock);
if(m_stSendSSQueue.size() > 0)
{
pNetPacket = m_stSendSSQueue.front();
m_stSendSSQueue.pop_front();
}
else
{
pNetPacket = NULL;
}
return S_OK;
}
//判断发送队列是否已满
bool CFrameNetQueue::IsSendSSQueueFull()
{
return false;
}
//判读发送队列是否为空
bool CFrameNetQueue::IsSendSSQueueEmpty()
{
MUTEX_GUARD(SendSSLock, m_stSendSSLock);
return m_stSendSSQueue.empty();
}
//从接收队列尾部追加一条消息
int32_t CFrameNetQueue::PushRecvCSQueue(NetPacket *pNetPacket)
{
if(pNetPacket == NULL)
{
return E_NULLPOINTER;
}
MUTEX_GUARD(RecvCSLock, m_stRecvCSLock);
m_stRecvCSQueue.push_back(pNetPacket);
return S_OK;
}
//从接收队列头部读取一条消息
int32_t CFrameNetQueue::PopRecvCSQueue(NetPacket *&pNetPacket)
{
MUTEX_GUARD(RecvCSLock, m_stRecvCSLock);
if(m_stRecvCSQueue.size() > 0)
{
pNetPacket = m_stRecvCSQueue.front();
m_stRecvCSQueue.pop_front();
}
else
{
pNetPacket = NULL;
}
return S_OK;
}
//判断接收队列是否已满
bool CFrameNetQueue::IsRecvCSQueueFull()
{
return false;
}
//判读接收队列是否为空
bool CFrameNetQueue::IsRecvCSQueueEmpty()
{
MUTEX_GUARD(RecvCSLock, m_stRecvCSLock);
return m_stRecvCSQueue.empty();
}
//从发送队列尾部追加一条消息
int32_t CFrameNetQueue::PushSendCSQueue(NetPacket *pNetPacket)
{
if(pNetPacket == NULL)
{
return E_NULLPOINTER;
}
MUTEX_GUARD(SendCSLock, m_stSendCSLock);
m_stSendCSQueue.push_back(pNetPacket);
return S_OK;
}
//从发送队列头部读取一条消息
int32_t CFrameNetQueue::PopSendCSQueue(NetPacket *&pNetPacket)
{
MUTEX_GUARD(SendCSLock, m_stSendCSLock);
if(m_stSendCSQueue.size() > 0)
{
pNetPacket = m_stSendCSQueue.front();
m_stSendCSQueue.pop_front();
}
else
{
pNetPacket = NULL;
}
return S_OK;
}
//判断发送队列是否已满
bool CFrameNetQueue::IsSendCSQueueFull()
{
return false;
}
//判读发送队列是否为空
bool CFrameNetQueue::IsSendCSQueueEmpty()
{
MUTEX_GUARD(SendCSLock, m_stSendCSLock);
return m_stSendCSQueue.empty();
}
FRAME_NAMESPACE_END