F #4936: Execute listener action outside lock (#148)

This commit is contained in:
Pavel Czerný authored and GitHub committed 2020-08-12 11:37:28 +02:00
1 parent d5f4153422
commit 238769f5eb
1 file changed
+12 -8
+12 -8
View File
@@ -162,19 +162,23 @@ protected:
{
end = false;
std::unique_lock<std::mutex> ul(lock);
while (true)
{
cond.wait(ul, [&]{return (end || !pending.empty());});
std::function<void()> fn;
if (end)
{
break;
}
std::unique_lock<std::mutex> ul(lock);
auto fn = pending.front();
pending.pop();
cond.wait(ul, [&]{return (end || !pending.empty());});
if (end)
{
break;
}
fn = pending.front();
pending.pop();
}
fn();
}