blob: f456a9d6a712f5f32f1645511c8fff923f315eaa (
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
34
35
36
37
38
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "document_subdb_initializer.h"
#include "idocumentsubdb.h"
#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/searchcorespi/index/i_thread_service.h>
using vespalib::makeLambdaTask;
namespace proton {
DocumentSubDbInitializer::DocumentSubDbInitializer(IDocumentSubDB &subDB, searchcorespi::index::IThreadService &master)
: InitTask(),
_result(),
_documentMetaStoreInitTask(),
_subDB(subDB),
_master(master)
{ }
void
DocumentSubDbInitializer::
addDocumentMetaStoreInitTask(InitTask::SP documentMetaStoreInitTask)
{
assert(!_documentMetaStoreInitTask);
_documentMetaStoreInitTask = documentMetaStoreInitTask;
addDependency(documentMetaStoreInitTask);
}
void
DocumentSubDbInitializer::run()
{
std::promise<void> promise;
auto future = promise.get_future();
_master.execute(makeLambdaTask([&]() { _subDB.setup(_result); promise.set_value(); }));
future.wait();
}
} // namespace proton
|