use lock_guard

This commit is contained in:
dimon4eg 2019-05-09 00:20:26 +03:00
parent 2727d39fa4
commit 28ae70ed20

View File

@ -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;
}