blob: 5c23ff8beb4cae5149b3b254ea10069ce885c703 [file] [log] [blame]
// Copyright 2023 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "vm_tools/concierge/thread_utils.h"
#include <utility>
namespace vm_tools::concierge {
void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner,
base::OnceCallback<void()> func) {
base::WaitableEvent event{};
task_runner->PostTask(FROM_HERE, base::BindOnce(
[](base::OnceCallback<void()> callback,
raw_ref<base::WaitableEvent> event) {
std::move(callback).Run();
event->Signal();
},
std::move(func), raw_ref(event)));
event.Wait();
}
} // namespace vm_tools::concierge