aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.h
blob: f65d5b0bad3098defc35b65558d691e74b25060f (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/vespalib/util/time.h>

namespace proton {

/**
 * Class used to track when commit is needed based on wanted visibility delay.
 */
class CommitTimeTracker
{
private:
    vespalib::duration             _visibilityDelay;
    mutable vespalib::steady_time  _nextCommit;

    bool hasVisibilityDelay() const { return _visibilityDelay != vespalib::duration::zero(); }
public:
    CommitTimeTracker(vespalib::duration visibilityDelay);
    bool needCommit() const;
};

} // namespace proton