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,8 +106,9 @@ 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);
if (lock.owns_lock()) {
auto it = m_Events.find(client); auto it = m_Events.find(client);
ASSERT(it != m_Events.end()); ASSERT(it != m_Events.end());
@ -117,6 +118,7 @@ Dictionary::Ptr EventQueue::WaitForEvent(void *client, boost::asio::yield_contex
return result; return result;
} }
} }
}
IoBoundWorkSlot dontLockTheIoThreadWhileWaiting (yc); IoBoundWorkSlot dontLockTheIoThreadWhileWaiting (yc);
} }