k**l 发帖数: 2966 | 1 I use a queue (deque) to store some broadcast messages for later process.
All messages were casted to char array with certain length.
say when I got a new broadcast with length n;
char* bcbuffer = new char [n];
memcpy(bcbuffer,broadcast,n);
m_broadcastQue.push(std::pair(bcbuffer,n));
Later when I process it:
char* bcbuffer =m_broadcastQue.front().first;
int n=m_broadcastQue.front().second;
m_broadcastQue.pop();//cut the link to free queue lock
processOneBroadCast(bcbuffer, n);
delete ... 阅读全帖 |
|