本文整理汇总了C++中MessageQueue::queueUnlck方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageQueue::queueUnlck方法的具体用法?C++ MessageQueue::queueUnlck怎么用?C++ MessageQueue::queueUnlck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageQueue
的用法示例。
在下文中一共展示了MessageQueue::queueUnlck方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMessage
void SocketConnect::sendMessage()
{
CCLOG("SEND THREAD HAS BEGAN !\n");
SOCKET socket = this->socketSet;
MessageQueue * queue = MessageQueueManager::getInstance()->getSendQueue();
while (true)
{
if (queue->getQueueSize() > 0)
{
CCLOG("SENDQUEUE SIZE IS %d\n",queue->getQueueSize());
queue->queueLck();
SocketMessage * msg = queue->frontQueue();
queue->queueUnlck();
CCLOG("SEND TO SERVER FROM SENDQUEUE : %s, DATA LENGTHT : %d\n",msg->getData().c_str(),msg->dataLength());
if (-1 == send(socket, msg->getData().c_str(), msg->dataLength(), 0)) {
CCLOG("SEND TO SERVER ERROR ! WILL BE TRY TO SEND AGAGIN !\n");
}
else{
CCLOG("SEND TO SERVER SUCCESS !\n");
queue->queueLck();
queue->popQueue();
queue->queueUnlck();
delete msg;
}
}
else{
// CCLOG("QUEUE IS EMPTY !");
}
}
}
示例2: revMessage
void SocketConnect::revMessage()
{
CCLOG("RECEIVE THREAD HAS BEGAN !\n");
SOCKET socket = this->socketSet;
char buf[1024] = "";
while (true) {
if (-1 == recv(socket, buf, sizeof(buf), 0)) {
CCLOG("RECEIVE ERROR !\n");
}
else{
MessageQueue * queue = MessageQueueManager::getInstance()->getRevQueue();
SocketMessage * msg = SocketMessage::create();
msg->setData(buf);
CCLOG("CLIENT HAS RECEIVE : %s",msg->getData().c_str());
if (msg->dataLength() > 0) {
queue->queueLck();
MessageQueueManager::getInstance()->sendMsgToRevQueue(msg);
queue->queueUnlck();
memset(buf, 0, 1024);
}else{
CCLOG("MAYBE SOMETHING WRONG !\n");
}
}
}
}