aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/updatedonecontext.h
blob: 3a43612f637764be50230bbb5c5098b07acc20ca (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.

#pragma once

#include "operationdonecontext.h"
#include <vespa/searchcore/proton/common/ipendinglidtracker.h>
#include <vespa/document/update/documentupdate.h>
#include <future>

namespace document { class Document; }

namespace proton {

/**
 * Context class for document update operations that acks operation when
 * instance is destroyed. Typically a shared pointer to an instance is
 * passed around to multiple worker threads that performs portions of
 * a larger task before dropping the shared pointer, triggering the
 * ack when all worker threads have completed.
 */
class UpdateDoneContext : public OperationDoneContext
{
    IPendingLidTracker::Token    _uncommitted;
    document::DocumentUpdate::SP _upd;
    std::shared_future<std::unique_ptr<const document::Document>> _doc;
public:
    UpdateDoneContext(std::shared_ptr<feedtoken::IState> token, IPendingLidTracker::Token uncommitted, const document::DocumentUpdate::SP &upd);
    ~UpdateDoneContext() override;

    const document::DocumentUpdate &getUpdate() { return *_upd; }
    void setDocument(std::shared_future<std::unique_ptr<const document::Document>> doc);
};


}  // namespace proton