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