1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

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

This commit is contained in:
Pavel Czerný 2020-08-12 11:37:28 +02:00 committed by GitHub
parent d5f4153422
commit 238769f5eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();
}