EventQueue#WaitForEvent(): don't lock I/O thread while locking mutex

This commit is contained in:
Alexander A. Klimov 2019-04-02 14:38:06 +02:00
parent dc0288fef8
commit 09a2e04f4b
1 changed files with 9 additions and 7 deletions

View File

@ -106,15 +106,17 @@ Dictionary::Ptr EventQueue::WaitForEvent(void *client, boost::asio::yield_contex
{
for (;;) {
{
boost::mutex::scoped_lock lock(m_Mutex);
boost::mutex::scoped_try_lock lock(m_Mutex);
auto it = m_Events.find(client);
ASSERT(it != m_Events.end());
if (lock.owns_lock()) {
auto it = m_Events.find(client);
ASSERT(it != m_Events.end());
if (!it->second.empty()) {
Dictionary::Ptr result = *it->second.begin();
it->second.pop_front();
return result;
if (!it->second.empty()) {
Dictionary::Ptr result = *it->second.begin();
it->second.pop_front();
return result;
}
}
}