Commit 72146e78 authored by Max Kellermann's avatar Max Kellermann

output/httpd: use std::lock_guard

parent f7af1bb8
...@@ -325,9 +325,10 @@ HttpdOutput::BroadcastPage(PagePtr page) ...@@ -325,9 +325,10 @@ HttpdOutput::BroadcastPage(PagePtr page)
{ {
assert(page != nullptr); assert(page != nullptr);
mutex.lock(); {
const std::lock_guard<Mutex> lock(mutex);
pages.emplace(std::move(page)); pages.emplace(std::move(page));
mutex.unlock(); }
DeferredMonitor::Schedule(); DeferredMonitor::Schedule();
} }
...@@ -336,15 +337,15 @@ void ...@@ -336,15 +337,15 @@ void
HttpdOutput::BroadcastFromEncoder() HttpdOutput::BroadcastFromEncoder()
{ {
/* synchronize with the IOThread */ /* synchronize with the IOThread */
mutex.lock(); {
const std::lock_guard<Mutex> lock(mutex);
while (!pages.empty()) while (!pages.empty())
cond.wait(mutex); cond.wait(mutex);
PagePtr page; PagePtr page;
while ((page = ReadPage()) != nullptr) while ((page = ReadPage()) != nullptr)
pages.push(page); pages.push(page);
}
mutex.unlock();
DeferredMonitor::Schedule(); DeferredMonitor::Schedule();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment