aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/flushengine/flushtask.cpp
blob: e26aaf10b72f5c5fc63799666d06d055fe4a7872 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "flushtask.h"
#include "flushengine.h"

namespace proton {

FlushTask::FlushTask(uint32_t taskId,
                     FlushEngine &engine,
                     std::shared_ptr<FlushContext> ctx)
    : _taskId(taskId),
      _engine(engine),
      _context(std::move(ctx))
{
    assert(_context);
}

FlushTask::~FlushTask()
{
    _engine.flushDone(*_context, _taskId);
}

void
FlushTask::run()
{
    searchcorespi::FlushTask::UP task(_context->getTask());
    search::SerialNum flushSerial(task->getFlushSerial());
    if (flushSerial != 0) {
        _context->getHandler()->syncTls(flushSerial);
    }
    task->run();
    task.reset();
}

} // namespace proton