use lock_guard
This commit is contained in:
parent
2727d39fa4
commit
28ae70ed20
@ -56,9 +56,10 @@ namespace ix
|
||||
message->openInfo = openInfo;
|
||||
message->closeInfo = closeInfo;
|
||||
|
||||
_messagesMutex.lock();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_messagesMutex);
|
||||
_messages.emplace_back(std::move(message));
|
||||
_messagesMutex.unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -72,14 +73,13 @@ namespace ix
|
||||
WebSocketMessageQueue::MessageDataPtr WebSocketMessageQueue::popMessage()
|
||||
{
|
||||
MessageDataPtr message;
|
||||
std::lock_guard<std::mutex> lock(_messagesMutex);
|
||||
|
||||
_messagesMutex.lock();
|
||||
if (!_messages.empty())
|
||||
{
|
||||
message = std::move(_messages.front());
|
||||
_messages.pop_front();
|
||||
}
|
||||
_messagesMutex.unlock();
|
||||
|
||||
return message;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user