From 2c8d004f78b6eb1df94747555a5e65e0a336251f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 26 Apr 2019 18:25:36 +0200 Subject: [PATCH] output/Control: add LockWaitForCommand() --- src/output/Control.hxx | 5 +++++ src/output/MultipleOutputs.cxx | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/output/Control.hxx b/src/output/Control.hxx index 9ec66a2e1..8c022e124 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -309,6 +309,11 @@ public: */ void WaitForCommand() noexcept; + void LockWaitForCommand() noexcept { + const std::lock_guard protect(mutex); + WaitForCommand(); + } + /** * Sends a command, but does not wait for completion. * diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index d8a73adf8..9130c7e79 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -158,10 +158,8 @@ MultipleOutputs::EnableDisable() void MultipleOutputs::WaitAll() noexcept { - for (const auto &ao : outputs) { - const std::lock_guard protect(ao->mutex); - ao->WaitForCommand(); - } + for (const auto &ao : outputs) + ao->LockWaitForCommand(); } void