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

View File

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