blob: 7b29bd5d0728f2aa0fb057cc714fb988980ad0b8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "document_db_directory_holder.h"
#include <mutex>
#include <condition_variable>
namespace proton {
namespace {
std::mutex mutex;
std::condition_variable cv;
}
DocumentDBDirectoryHolder::DocumentDBDirectoryHolder()
{
}
DocumentDBDirectoryHolder::~DocumentDBDirectoryHolder()
{
std::lock_guard guard(mutex);
cv.notify_all();
}
void
DocumentDBDirectoryHolder::waitUntilDestroyed(const std::weak_ptr<DocumentDBDirectoryHolder> &holder)
{
std::unique_lock guard(mutex);
cv.wait(guard, [&]() { return !holder.lock(); });
}
} // namespace proton
|